diff --git a/CHANGELOG.md b/CHANGELOG.md index faf0c44..f56cb5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [v0.3.1] - 2022-03-12 (Beta) + +### Fixes + +- Fixes a `protoc-gen-frisbee` bug where the client message type didn't have the correct offset + ## [v0.3.0] - 2022-03-12 (Beta) ### Changes diff --git a/protoc-gen-frisbee/dockerfile b/protoc-gen-frisbee/dockerfile new file mode 100644 index 0000000..bc12675 --- /dev/null +++ b/protoc-gen-frisbee/dockerfile @@ -0,0 +1,19 @@ +FROM golang as builder + +ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=0 + +RUN go install github.com/loopholelabs/frisbee/protoc-gen-frisbee@v0.3.0 + +# Note, the Docker images must be built for amd64. If the host machine architecture is not amd64 +# you need to cross-compile the binary and move it into /go/bin. +RUN bash -c 'find /go/bin/${GOOS}_${GOARCH}/ -mindepth 1 -maxdepth 1 -exec mv {} /go/bin \;' + +FROM scratch + +# Runtime dependencies +LABEL "build.buf.plugins.runtime_library_versions.0.name"="github.com/loopholelabs/frisbee" +LABEL "build.buf.plugins.runtime_library_versions.0.version"="v0.3.0" + +COPY --from=builder /go/bin / + +ENTRYPOINT ["/protoc-gen-frisbee"] diff --git a/protoc-gen-frisbee/pkg/generator/client.go b/protoc-gen-frisbee/pkg/generator/client.go index f31cbf7..1869884 100644 --- a/protoc-gen-frisbee/pkg/generator/client.go +++ b/protoc-gen-frisbee/pkg/generator/client.go @@ -53,7 +53,7 @@ func writeClientMethod(f File, method protoreflect.MethodDescriptor, operation i f.P("func (c *Client) ", utils.CamelCase(string(method.Name())), "(ctx context.Context, req *", utils.CamelCase(string(method.Input().FullName())), ") (res *", utils.CamelCase(string(method.Output().FullName())), ", err error) {") f.P(tab, "ch := make(chan *", utils.CamelCase(string(method.Output().FullName())), ", 1)") f.P(tab, "p := packet.Get()") - f.P(tab, "p.Metadata.Operation = ", operation) + f.P(tab, "p.Metadata.Operation = ", operation+operationOffset) f.P("LOOP:") f.P(tab, "p.Metadata.Id = c.next", utils.CamelCase(string(method.Name())), ".Load().(uint16)") f.P(tab, "if !c.next", utils.CamelCase(string(method.Name())), ".CompareAndSwap(p.Metadata.Id, p.Metadata.Id+1) {") @@ -87,7 +87,7 @@ func writeClientMethod(f File, method protoreflect.MethodDescriptor, operation i func writeClientIgnoreMethod(f File, method protoreflect.MethodDescriptor, operation int) { f.P("func (c *Client) ", utils.CamelCase(string(method.Name())), "Ignore(ctx context.Context, req *", utils.CamelCase(string(method.Input().FullName())), ") (err error) {") f.P(tab, "p := packet.Get()") - f.P(tab, "p.Metadata.Operation = ", operation) + f.P(tab, "p.Metadata.Operation = ", operation+operationOffset) f.P("LOOP:") f.P(tab, "p.Metadata.Id = c.next", utils.CamelCase(string(method.Name())), ".Load().(uint16)") f.P(tab, "if !c.next", utils.CamelCase(string(method.Name())), ".CompareAndSwap(p.Metadata.Id, p.Metadata.Id+1) {")