Skip to content

Commit

Permalink
Move proto/buf to buf and add ioext.CompositeReadWriteCloser (#2749)
Browse files Browse the repository at this point in the history
  • Loading branch information
bufdev authored Feb 2, 2024
1 parent 78a606d commit 231f6aa
Show file tree
Hide file tree
Showing 50 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion buf.work.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version: v1
directories:
- proto/buf
- proto
4 changes: 2 additions & 2 deletions make/buf/all.mk
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ bufgenerateclean:: \

.PHONY: bufgenerateprotogo
bufgenerateprotogo:
$(BUF_BIN) generate proto/buf --template data/template/buf.go.gen.yaml
$(BUF_BIN) generate proto --template data/template/buf.go.gen.yaml
$(BUF_BIN) generate buf.build/grpc/grpc --type grpc.reflection.v1.ServerReflection --template data/template/buf.go.gen.yaml

.PHONY: bufgenerateprotogoclient
bufgenerateprotogoclient:
$(BUF_BIN) generate proto/buf --template data/template/buf.go-client.gen.yaml
$(BUF_BIN) generate proto --template data/template/buf.go-client.gen.yaml

.PHONY: bufgeneratebuflinttestdata
bufgeneratebuflinttestdata:
Expand Down
11 changes: 11 additions & 0 deletions private/pkg/ioext/ioext.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ func CompositeWriteCloser(writer io.Writer, closer io.Closer) io.WriteCloser {
return compositeWriteCloser{Writer: writer, Closer: closer}
}

// CompositeReadWriteCloser returns a io.ReadWriteCloser that is a composite of the Reader, Writer, and Closer.
func CompositeReadWriteCloser(reader io.Reader, writer io.Writer, closer io.Closer) io.ReadWriteCloser {
return compositeReadWriteCloser{Reader: reader, Writer: writer, Closer: closer}
}

// ChainCloser chains the closers by calling them in order.
func ChainCloser(closers ...io.Closer) io.Closer {
return chainCloser{closers: closers}
Expand Down Expand Up @@ -119,6 +124,12 @@ type compositeWriteCloser struct {
io.Closer
}

type compositeReadWriteCloser struct {
io.Reader
io.Writer
io.Closer
}

type chainCloser struct {
closers []io.Closer
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 231f6aa

Please sign in to comment.