From c50c0b4bcfc56cfe57277bc0b562585cd4dea119 Mon Sep 17 00:00:00 2001 From: Shivansh Vij Date: Mon, 2 Sep 2024 20:58:36 -0700 Subject: [PATCH] Updating license headers, bumping CI/CD dependencies, and transitioning to Loophole logging library --- .github/ISSUE_TEMPLATE/bug_report.md | 24 -------- .github/ISSUE_TEMPLATE/config.yml | 5 -- .github/ISSUE_TEMPLATE/feature_request.md | 19 ------ .github/ISSUE_TEMPLATE/other.md | 13 ----- .github/PULL_REQUEST_TEMPLATE.md | 35 ----------- .github/dependabot.yml | 11 ++++ .github/workflows/lint.yml | 10 ++-- .github/workflows/tests.yaml | 71 +++++++---------------- .markdownlint.yaml | 13 ----- CHANGELOG.md | 62 -------------------- README.md | 12 +--- dockerfile | 19 ------ docs/getting-started/quick-start.mdx | 1 - docs/reference/client-methods.mdx | 6 +- docs/reference/server-methods.mdx | 8 +-- go.mod | 10 +--- go.sum | 21 ++----- internal/version/current_version | 1 - internal/version/version.go | 24 -------- pkg/generator/generator.go | 23 ++------ pkg/generator/headers.go | 16 +---- pkg/generator/imports.go | 22 ++----- pkg/generator/server.go | 19 +----- pkg/generator/test/generator_test.go | 16 +---- pkg/generator/test/server.go | 16 +---- pkg/generator/test/test.frpc.go | 16 ++--- protoc-gen-go-frpc/main.go | 16 +---- templates/client.templ | 3 +- templates/server.templ | 3 +- version/current_version | 1 + version/version.go | 10 ++++ 31 files changed, 89 insertions(+), 437 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/config.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 .github/ISSUE_TEMPLATE/other.md delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/dependabot.yml delete mode 100644 .markdownlint.yaml delete mode 100644 CHANGELOG.md delete mode 100644 dockerfile delete mode 100644 internal/version/current_version delete mode 100644 internal/version/version.go create mode 100644 version/current_version create mode 100644 version/version.go diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index ec734a4..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: "" -labels: bug -assignees: ShivanshVij ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: - -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index bd16e94..0000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,5 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: Loophole Labs Community Support - url: https://loopholelabs.io/discord - about: Please ask and answer questions here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 62a0781..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: "" -labels: enhancement -assignees: ShivanshVij ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/other.md b/.github/ISSUE_TEMPLATE/other.md deleted file mode 100644 index 1175381..0000000 --- a/.github/ISSUE_TEMPLATE/other.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -name: Other -about: A different type of issue -title: "" -labels: question -assignees: ShivanshVij ---- - -**Description of the Issue. Please be as clear as possible.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Additional context** -Add any other context or screenshots about the issue here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5a16e09..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,35 +0,0 @@ -## Description - -Please include a summary of the change and which issue has been fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. - -Fixes # (issue) - -## Type of change - -**Please update the title of this PR to reflect the type of change.** (Delete the ones that aren't required). - -- [ ] Bug fix (non-breaking change which fixes an issue) [title: 'fix:'] -- [ ] New feature (non-breaking change which adds functionality) [title: 'feat:'] -- [ ] Refactor (non-breaking code changes that do not add new functionality or break existing functionality) [title: 'refactor:'] -- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) -- [ ] This change requires a documentation update - -## Testing - -Please make sure that existing test cases pass (with `go test ./... -race` and `go test -bench=. ./... -race`), -and if required please add new test cases and list them below: - -- [ ] Test A -- [ ] Test B - -## Final Checklist: - -- [ ] My code follows the style guidelines of this project -- [ ] I have performed a self-review of my own code -- [ ] I have commented my code, particularly in hard-to-understand areas -- [ ] I have made corresponding changes to the documentation -- [ ] My changes generate no new warnings -- [ ] I have added tests that prove my fix is effective or that my feature works -- [ ] New and existing unit tests pass locally with my changes -- [ ] Any dependent changes have been merged and published in downstream modules -- [ ] I have checked my code and corrected any misspellings diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..cd88554 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "gomod" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b2e6449..dee5dbf 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,13 +7,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Golang - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: '1.21' - cache: false + go-version: '1.22' + cache: true - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6 with: version: latest diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index eb1d523..396efe8 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,96 +1,65 @@ name: Tests -on: - push: - branches: - - "*" - pull_request: - branches: - - "*" +on: [pull_request] jobs: tests: runs-on: ubuntu-latest steps: - - id: go-cache-paths - run: | - echo "::set-output name=go-build::$(go env GOCACHE)" - echo "::set-output name=go-mod::$(go env GOMODCACHE)" - - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: '1.21' - - - name: Go Build Cache - uses: actions/cache@v2 - with: - path: ${{ steps.go-cache-paths.outputs.go-build }} - key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - - - name: Go Mod Cache - uses: actions/cache@v2 + uses: actions/setup-go@v5 with: - path: ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + go-version: '1.22' + cache: true - - uses: actions/checkout@v3 - name: Install Protoc - uses: arduino/setup-protoc@v1 + uses: arduino/setup-protoc@v3 + - name: Install protoc-gen plugin working-directory: ./protoc-gen-go-frpc run: go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + - name: Install frpc plugin for protoc-gen working-directory: ./ run: go install ./protoc-gen-go-frpc + - name: Run generator working-directory: ./examples/test run: protoc --go-frpc_out=../../pkg/generator test.proto + - name: Test run: go test -v ./... + tests-race: runs-on: ubuntu-latest steps: - - id: go-cache-paths - run: | - echo "::set-output name=go-build::$(go env GOCACHE)" - echo "::set-output name=go-mod::$(go env GOMODCACHE)" - - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: - go-version: '1.21' - - - name: Go Build Cache - uses: actions/cache@v2 - with: - path: ${{ steps.go-cache-paths.outputs.go-build }} - key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - - - name: Go Mod Cache - uses: actions/cache@v2 - with: - path: ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + go-version: '1.22' + cache: true - name: Install Protoc - uses: arduino/setup-protoc@v1 + uses: arduino/setup-protoc@v3 + - name: Install protoc-gen plugin working-directory: ./protoc-gen-go-frpc run: go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + - name: Install frpc plugin for protoc-gen working-directory: ./ run: go install ./protoc-gen-go-frpc + - name: Run generator working-directory: ./examples/test run: protoc --go-frpc_out=../../pkg/generator test.proto - name: Test with Race Conditions run: go test -race -v ./... - timeout-minutes: 15 + timeout-minutes: 15 \ No newline at end of file diff --git a/.markdownlint.yaml b/.markdownlint.yaml deleted file mode 100644 index 8572168..0000000 --- a/.markdownlint.yaml +++ /dev/null @@ -1,13 +0,0 @@ -# Autoformatter friendly markdownlint config (all formatting rules disabled) -default: true -blank_lines: false -bullet: false -html: false -indentation: false -line_length: false -spaces: false -url: false -whitespace: false -first-line-h1: false -no-trailing-punctuation: false -no-duplicate-header: false diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 8353724..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,62 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres -to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [Unreleased] - -## [v0.7.2] - 2022-12-10 - -### Fixes - -- Fixed a bug where stream handlers would be generated for a proto file without streams - -## [v0.7.1] - 2022-12-10 - -### Changes - -- Fixed a bug when generating fRPC with streams where sometimes stream messages would be received out of order. -- Removed the Trunk linter - -## [v0.7.0] - 2022-09-28 - -### Features - -- fRPC now uses the `VarInt` encoding format under the hood (added in [polyglot-go v0.5.0](https://github.com/loopholelabs/polyglot-go)) which should help reduce the number of bytes an RPC call is serialized to -- A new `CloseError` type has been added which, when returned by an RPC call, causes the connection to be closed after the message is written. This can be useful for authentication or connection management. -- Streaming is now available! The API matches gRPC's so it should be a drop-in replacement! - -### Changes - -- The [polyglot-go](https://github.com/loopholelabs/polyglot-go) dependency has been bumped to `v0.5.0` -- The [frisbee-go](https://github.com/loopholelabs/frisbee-go) dependency has been b umped to `v0.7.0` - -## [v0.6.0] - 2022-08-24 (Beta) - -### Changes - -- Refactoring the generated code to use the [polyglot-go](https://github.com/loopholelabs/polyglot-go) library to generate message encode/decode functions. ([#3](https://github.com/loopholelabs/frpc-go/pull/3)) - -### Fixes - -- Fixed an issue with the generated code that caused compilation issues when the names of two methods in different services - were the same ([#5](https://github.com/loopholelabs/frpc-go/issues/5)) - -## [v0.5.1] - 2022-07-20 (Beta) - -### Fixes - -- Fixed an issue where if the number of services is 0 the RPC Generator would - crash ([#101](https://github.com/loopholelabs/frisbee-go/issues/101)) - -> Changelogs for [v0.5.0] and before can be found at https://github.com/loopholelabs/frisbee-go - -[unreleased]: https://github.com/loopholelabs/frpc-go/compare/v0.7.2...HEAD -[v0.7.2]: https://github.com/loopholelabs/frpc-go/releases/tag/v0.7.2 -[v0.7.1]: https://github.com/loopholelabs/frpc-go/releases/tag/v0.7.1 -[v0.7.0]: https://github.com/loopholelabs/frpc-go/releases/tag/v0.7.0 -[v0.6.0]: https://github.com/loopholelabs/frpc-go/releases/tag/v0.6.0 -[v0.5.1]: https://github.com/loopholelabs/frpc-go/releases/tag/v0.5.1 -[v0.5.0]: https://github.com/loopholelabs/frisbee-go/compare/v0.4.6...v0.5.0 diff --git a/README.md b/README.md index 241df2f..0a95fa8 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,13 @@ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![Tests](https://github.com/loopholelabs/frpc-go/actions/workflows/tests.yaml/badge.svg)](https://github.com/loopholelabs/frpc-go/actions/workflows/tests.yaml) +[![Discord](https://dcbadge.vercel.app/api/server/JYmFhtdPeu?style=flat)](https://loopholelabs.io/discord) +![Go Version](https://img.shields.io/badge/go%20version-%3E=1.22-61CFDD.svg) + This is the [Go](http://golang.org) implementation of [fRPC](https://frpc.io), a modern RPC framework designed for high performance and stability, that uses the [frisbee-go](https://github.com/loopholelabs/frisbee-go) messaging framework under the hood. -**This library requires Go1.18 or later.** - -## Important note about releases and stability - -This repository generally follows [Semantic Versioning](https://semver.org/). However, **this library is currently in -Alpha** and is still considered experimental. Breaking changes of the library will _not_ trigger a new major release. The -same is true for selected other new features explicitly marked as -**EXPERIMENTAL** in [the changelog](/CHANGELOG.md). - ## Usage and Documentation Usage instructions and documentation for fRPC is available at [https://frpc.io/](https://frpc.io/). diff --git a/dockerfile b/dockerfile deleted file mode 100644 index 291578f..0000000 --- a/dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM golang as builder - -ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=0 - -RUN go install github.com/loopholelabs/frpc-go/protoc-gen-go-frpc@v0.7.3 - -# 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/frpc-go" -LABEL "build.buf.plugins.runtime_library_versions.0.version"="v0.7.3" - -COPY --from=builder /go/bin / - -ENTRYPOINT ["/protoc-gen-go-frpc"] \ No newline at end of file diff --git a/docs/getting-started/quick-start.mdx b/docs/getting-started/quick-start.mdx index 57a03c2..d544e62 100644 --- a/docs/getting-started/quick-start.mdx +++ b/docs/getting-started/quick-start.mdx @@ -166,7 +166,6 @@ package main import ( "context" - "github.com/rs/zerolog" "frpc/echo" "log" "os" diff --git a/docs/reference/client-methods.mdx b/docs/reference/client-methods.mdx index 7e4c6fb..6028f86 100644 --- a/docs/reference/client-methods.mdx +++ b/docs/reference/client-methods.mdx @@ -4,12 +4,12 @@ title: Client Methods # NewClient -The `NewClient(tlsConfig *tls.Config, logger *zerolog.Logger) (*Client, error)` method is used to create a new fRPC client. +The `NewClient(tlsConfig *tls.Config, logger types.Logger) (*Client, error)` method is used to create a new fRPC client. It takes two arguments: - `tlsConfig`: a `*tls.Config` that will be used to configure TLS for the underlying connection. This can be left as `nil` if no TLS is required. -- `logger`: a `*zerolog.Logger` that will be used to log all events. This can be left as `nil` if no logging is required. +- `logger`: a `types.Logger` that will be used to log all events. This can be left as `nil` if no logging is required. It returns an fRPC `*Client` on success and an error otherwise. @@ -73,7 +73,7 @@ The `Raw() (net.Conn, error)` method is used to get the underlying `net.Conn` fr # Logger -The `Logger() *zerolog.Logger` method is used to get the logger that was provided when the client was created. This is useful if you want to extend fRPC with custom protocols or messaging patterns directly for use with the underlying Frisbee library. +The `Logger() types.Logger` method is used to get the logger that was provided when the client was created. This is useful if you want to extend fRPC with custom protocols or messaging patterns directly for use with the underlying Frisbee library. # Generated Methods diff --git a/docs/reference/server-methods.mdx b/docs/reference/server-methods.mdx index 6716869..28ce09d 100644 --- a/docs/reference/server-methods.mdx +++ b/docs/reference/server-methods.mdx @@ -4,7 +4,7 @@ title: Server Methods # NewServer -The `NewServer(... Services, *tls.Config, *zerolog.Logger) (*Server, error)` method is used to create a new fRPC Server. It takes a list of structs that implement +The `NewServer(... Services, *tls.Config, *ypes.Logger) (*Server, error)` method is used to create a new fRPC Server. It takes a list of structs that implement the RPC methods corresponding to the services defined in the `.proto` file. For example, if the `.proto` file contains the following service definition: @@ -34,7 +34,7 @@ type OtherService interface { And the corresponding generated `NewServer` method would be: ```go -func NewServer(myService MyService, otherService OtherService, tlsConfig *tls.Config, logger *zerolog.Logger) (*Server, error) { +func NewServer(myService MyService, otherService OtherService, tlsConfig *tls.Config, logger types.Logger) (*Server, error) { ... } ``` @@ -42,7 +42,7 @@ func NewServer(myService MyService, otherService OtherService, tlsConfig *tls.Co The generated `NewServer` method also takes the additional two arguments: - `tlsConfig`: a `*tls.Config` that will be used to configure TLS for fRPC server. This can be left as `nil` if no TLS is required. -- `logger`: a `*zerolog.Logger` that will be used to log all events. This can be left as `nil` if no logging is required. +- `logger`: a `types.Logger` that will be used to log all events. This can be left as `nil` if no logging is required. It returns an fRPC `*Server` on success and an error otherwise. @@ -92,7 +92,7 @@ encounters an error, the `OnClosed` callback function will be called with the er # Logger -The `Logger() *zerolog.Logger` method is used to retrieve the logger for the fRPC server. This is useful if you want to retrieve and extend the fRPC server. +The `Logger() types.Logger` method is used to retrieve the logger for the fRPC server. This is useful if you want to retrieve and extend the fRPC server. # Shutdown diff --git a/go.mod b/go.mod index efdb51b..9ae391c 100644 --- a/go.mod +++ b/go.mod @@ -1,23 +1,19 @@ module github.com/loopholelabs/frpc-go -go 1.21.4 +go 1.22 require ( - github.com/loopholelabs/frisbee-go v0.8.1 + github.com/loopholelabs/frisbee-go v0.9.0 + github.com/loopholelabs/logging v0.3.0 github.com/loopholelabs/polyglot/v2 v2.0.1 github.com/loopholelabs/testing v0.2.3 - github.com/rs/zerolog v1.33.0 github.com/stretchr/testify v1.9.0 - go.uber.org/atomic v1.11.0 google.golang.org/protobuf v1.34.2 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/loopholelabs/common v0.4.9 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/sys v0.22.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 67fbd88..d5b9bbc 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ -github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -10,35 +8,28 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/loopholelabs/common v0.4.9 h1:9MPUYlZZ/qx3Kt8LXgXxcSXthrM91od8026c4DlGpAU= github.com/loopholelabs/common v0.4.9/go.mod h1:Wop5srN1wYT+mdQ9gZ+kn2I9qKAyVd0FB48pThwIa9M= -github.com/loopholelabs/frisbee-go v0.8.1 h1:muH8PhvyYz2jd0+T7c48L+FhYUGblkAhlbJNFKh3jLg= -github.com/loopholelabs/frisbee-go v0.8.1/go.mod h1:A2sNAaojm71/ZqA/VzJvRksReOt4tAfY1/bh6XKdGzQ= +github.com/loopholelabs/frisbee-go v0.9.0 h1:zBsEnre4MFO2a0S6G6Xx/1qRbR4qQJBDIHPi+UbhvAU= +github.com/loopholelabs/frisbee-go v0.9.0/go.mod h1:PJQMHfg07MAJGAPW3ke2Zo90ro5MxFr/QppFQ3aS5U4= +github.com/loopholelabs/logging v0.3.0 h1:Rfo9fGdBk4nwbNdiLrVUF7JkYoC67dvGDodkRe81xF0= +github.com/loopholelabs/logging v0.3.0/go.mod h1:uRDUydiqPqKbZkb0WoQ3dfyAcJ2iOMhxdEafZssLVv0= github.com/loopholelabs/polyglot/v2 v2.0.1 h1:JVSrXwx3jzr6/IrUe7Y1f7R3I6bFaVjLlPNLjJlmQaU= github.com/loopholelabs/polyglot/v2 v2.0.1/go.mod h1:kFoSKvnKAWmV0ICfbaCHDv/+cz5LSuA+xXG4WtYV/z4= github.com/loopholelabs/testing v0.2.3 h1:4nVuK5ctaE6ua5Z0dYk2l7xTFmcpCYLUeGjRBp8keOA= github.com/loopholelabs/testing v0.2.3/go.mod h1:gqtGY91soYD1fQoKQt/6kP14OYpS7gcbcIgq5mc9m8Q= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= diff --git a/internal/version/current_version b/internal/version/current_version deleted file mode 100644 index b19b521..0000000 --- a/internal/version/current_version +++ /dev/null @@ -1 +0,0 @@ -v0.8.0 diff --git a/internal/version/version.go b/internal/version/version.go deleted file mode 100644 index 2a5dab3..0000000 --- a/internal/version/version.go +++ /dev/null @@ -1,24 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package version - -import ( - _ "embed" -) - -//go:embed current_version -var Version string diff --git a/pkg/generator/generator.go b/pkg/generator/generator.go index 7c062ea..cf48dd7 100644 --- a/pkg/generator/generator.go +++ b/pkg/generator/generator.go @@ -1,18 +1,4 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +// SPDX-License-Identifier: Apache-2.0 package generator @@ -21,15 +7,16 @@ import ( "strings" "text/template" - generator "github.com/loopholelabs/polyglot/v2/generator/golang" - "github.com/loopholelabs/polyglot/v2/utils" "google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/types/pluginpb" - "github.com/loopholelabs/frpc-go/internal/version" + generator "github.com/loopholelabs/polyglot/v2/generator/golang" + "github.com/loopholelabs/polyglot/v2/utils" + "github.com/loopholelabs/frpc-go/templates" + "github.com/loopholelabs/frpc-go/version" ) type Generator struct { diff --git a/pkg/generator/headers.go b/pkg/generator/headers.go index 9e387a6..c692198 100644 --- a/pkg/generator/headers.go +++ b/pkg/generator/headers.go @@ -1,18 +1,4 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +// SPDX-License-Identifier: Apache-2.0 package generator diff --git a/pkg/generator/imports.go b/pkg/generator/imports.go index a7640a9..4cd30f7 100644 --- a/pkg/generator/imports.go +++ b/pkg/generator/imports.go @@ -1,26 +1,12 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +// SPDX-License-Identifier: Apache-2.0 package generator var ( requiredImports = []string{ "errors", - "github.com/loopholelabs/polyglot/v2", "net", + "github.com/loopholelabs/polyglot/v2", } serviceImports = []string{ @@ -28,11 +14,11 @@ var ( "crypto/tls", "github.com/loopholelabs/frisbee-go", "github.com/loopholelabs/frisbee-go/pkg/packet", - "github.com/rs/zerolog", + "github.com/loopholelabs/logging/types", } streamMethodImports = []string{ - "go.uber.org/atomic", + "sync/atomic", "io", } diff --git a/pkg/generator/server.go b/pkg/generator/server.go index f7cd751..f28eb32 100644 --- a/pkg/generator/server.go +++ b/pkg/generator/server.go @@ -1,26 +1,13 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +// SPDX-License-Identifier: Apache-2.0 package generator import ( "strings" - "github.com/loopholelabs/polyglot/v2/utils" "google.golang.org/protobuf/reflect/protoreflect" + + "github.com/loopholelabs/polyglot/v2/utils" ) func getServerFields(services protoreflect.ServiceDescriptors) string { diff --git a/pkg/generator/test/generator_test.go b/pkg/generator/test/generator_test.go index 936645c..df2770c 100644 --- a/pkg/generator/test/generator_test.go +++ b/pkg/generator/test/generator_test.go @@ -1,18 +1,4 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +// SPDX-License-Identifier: Apache-2.0 package test diff --git a/pkg/generator/test/server.go b/pkg/generator/test/server.go index a8100fa..d0d151f 100644 --- a/pkg/generator/test/server.go +++ b/pkg/generator/test/server.go @@ -1,18 +1,4 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +// SPDX-License-Identifier: Apache-2.0 package test diff --git a/pkg/generator/test/test.frpc.go b/pkg/generator/test/test.frpc.go index 9ab0aef..1b8800e 100644 --- a/pkg/generator/test/test.frpc.go +++ b/pkg/generator/test/test.frpc.go @@ -1,4 +1,4 @@ -// Code generated by fRPC Go v0.8.0, DO NOT EDIT. +// Code generated by fRPC Go v0.9.0, DO NOT EDIT. // source: test.proto package test @@ -12,12 +12,12 @@ import ( "crypto/tls" "github.com/loopholelabs/frisbee-go" "github.com/loopholelabs/frisbee-go/pkg/packet" - "github.com/rs/zerolog" + "github.com/loopholelabs/logging/types" "sync" - "go.uber.org/atomic" "io" + "sync/atomic" ) var ( @@ -1516,7 +1516,7 @@ type Server struct { onClosed func(*frisbee.Async, error) } -func NewServer(echoService EchoService, tlsConfig *tls.Config, logger *zerolog.Logger) (*Server, error) { +func NewServer(echoService EchoService, tlsConfig *tls.Config, logger types.Logger) (*Server, error) { var s *Server table := make(frisbee.HandlerTable) @@ -1628,7 +1628,6 @@ type EchoStreamServer struct { func (s *Server) createEchoStreamServer(echoService EchoService, stream *frisbee.Stream) { srv := &EchoStreamServer{ - closed: atomic.NewBool(false), stream: stream, } @@ -1701,7 +1700,6 @@ type SearchServer struct { func (s *Server) createSearchServer(echoService EchoService, stream *frisbee.Stream) { srv := &SearchServer{ - closed: atomic.NewBool(false), stream: stream, } @@ -1757,7 +1755,6 @@ type UploadServer struct { func (s *Server) createUploadServer(echoService EchoService, stream *frisbee.Stream) { srv := &UploadServer{ - closed: atomic.NewBool(false), stream: stream, } @@ -1835,7 +1832,7 @@ type Client struct { EchoService *subEchoServiceClient } -func NewClient(tlsConfig *tls.Config, logger *zerolog.Logger) (*Client, error) { +func NewClient(tlsConfig *tls.Config, logger types.Logger) (*Client, error) { c := new(Client) table := make(frisbee.HandlerTable) @@ -1957,7 +1954,6 @@ func (c *subEchoServiceClient) EchoStream(ctx context.Context, req *Request) (*E stream := EchoStreamClient{ context: ctx, stream: fStream, - closed: atomic.NewBool(false), } stream.recv = func() (*Response, error) { @@ -2080,7 +2076,6 @@ func (c *subEchoServiceClient) Search(ctx context.Context, req *SearchResponse) stream := SearchClient{ context: ctx, stream: fStream, - closed: atomic.NewBool(false), } stream.recv = func() (*Response, error) { @@ -2154,7 +2149,6 @@ func (c *subEchoServiceClient) Upload(ctx context.Context, req *Data) (*UploadCl stream := UploadClient{ context: ctx, stream: fStream, - closed: atomic.NewBool(false), } stream.recv = func() (*Response, error) { diff --git a/protoc-gen-go-frpc/main.go b/protoc-gen-go-frpc/main.go index bbef9d8..27ff7f1 100644 --- a/protoc-gen-go-frpc/main.go +++ b/protoc-gen-go-frpc/main.go @@ -1,18 +1,4 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ +// SPDX-License-Identifier: Apache-2.0 package main diff --git a/templates/client.templ b/templates/client.templ index 5343e78..d2621ce 100644 --- a/templates/client.templ +++ b/templates/client.templ @@ -26,7 +26,7 @@ type Client struct { {{end -}} } -func NewClient (tlsConfig *tls.Config, logger *zerolog.Logger) (*Client, error) { +func NewClient (tlsConfig *tls.Config, logger types.Logger) (*Client, error) { c := new(Client) table := make(frisbee.HandlerTable) {{template "clienthandlers" .services -}} @@ -144,7 +144,6 @@ func (e CloseError) Error() string { stream := {{ CamelCaseName $method.Name }}Client{ context: ctx, stream: fStream, - closed: atomic.NewBool(false), } stream.recv = func () (*{{ CamelCase $method.Output.FullName }}, error) { diff --git a/templates/server.templ b/templates/server.templ index 6cbb642..340bdd6 100644 --- a/templates/server.templ +++ b/templates/server.templ @@ -33,7 +33,7 @@ type Server struct { onClosed func(*frisbee.Async, error) } -func NewServer({{ GetServerFields .services }}, tlsConfig *tls.Config, logger *zerolog.Logger) (*Server, error) { +func NewServer({{ GetServerFields .services }}, tlsConfig *tls.Config, logger types.Logger) (*Server, error) { var s *Server table := make(frisbee.HandlerTable) {{template "serverhandlers" .services -}} @@ -125,7 +125,6 @@ func (s *Server) SetOnClosed(f func(*frisbee.Async, error)) error { func (s *Server) create{{ CamelCaseName $method.Name}}Server ({{ FirstLowerCase (CamelCaseName $service.Name) }} {{ CamelCaseName $service.Name }}, stream *frisbee.Stream) { srv := &{{ CamelCaseName $method.Name }}Server{ - closed: atomic.NewBool(false), stream: stream, } diff --git a/version/current_version b/version/current_version new file mode 100644 index 0000000..f979ade --- /dev/null +++ b/version/current_version @@ -0,0 +1 @@ +v0.9.0 diff --git a/version/version.go b/version/version.go new file mode 100644 index 0000000..2a2297a --- /dev/null +++ b/version/version.go @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: Apache-2.0 + +package version + +import ( + _ "embed" +) + +//go:embed current_version +var Version string