Skip to content

Commit

Permalink
Merge pull request #81 from loopholelabs/staging
Browse files Browse the repository at this point in the history
Releasing v0.3.1
  • Loading branch information
ShivanshVij authored Mar 13, 2022
2 parents 7ea7472 + f171894 commit 7c10aed
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions protoc-gen-frisbee/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM golang as builder

ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=0

RUN go install github.com/loopholelabs/frisbee/[email protected]

# 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"]
4 changes: 2 additions & 2 deletions protoc-gen-frisbee/pkg/generator/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {")
Expand Down Expand Up @@ -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) {")
Expand Down

0 comments on commit 7c10aed

Please sign in to comment.