Skip to content

Commit d862899

Browse files
feat: implement buf connect server (#1038)
* generate buf connect stub * create buf conenct server with dummy impl of all the RPCs * change default port to 8002 * update buf connect rpc plugin * add healthcheck * refactor * feat: add curl in the Dockerfile to support K8s exec probe * remove curl * update lint * add graceful shutdown of connect server * remove toolchain * update golang version * debug: update lint * debug: update lint * debug: update lint * debug: update lint * fix: upgrade to golangci-lint v2 * fix: upgrade to golangci-lint v2 * add error handling in buf connect server init * change grace period
1 parent 047b7ef commit d862899

File tree

22 files changed

+7016
-81
lines changed

22 files changed

+7016
-81
lines changed

.github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ jobs:
1313
steps:
1414
- uses: actions/setup-go@v4
1515
with:
16-
go-version: "1.22.5"
16+
go-version: "1.23.1"
1717
- uses: actions/checkout@v3
1818
with:
1919
fetch-depth: 0
2020
- name: golangci-lint
21-
uses: golangci/golangci-lint-action@v3
21+
uses: golangci/golangci-lint-action@v8
2222
with:
23-
version: v1.56.2
23+
version: v2.2.1
2424
js-sdk-lint:
2525
name: JS SDK Lint
2626
runs-on: ubuntu-latest

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Go
1616
uses: actions/setup-go@v4
1717
with:
18-
go-version: "1.22.5"
18+
go-version: "1.23.1"
1919
- name: Login to DockerHub
2020
uses: docker/login-action@v3
2121
with:

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v4
1919
with:
20-
go-version: "1.22.5"
20+
go-version: "1.23.1"
2121
- name: Login to DockerHub
2222
uses: docker/login-action@v3
2323
with:
@@ -41,7 +41,7 @@ jobs:
4141
- name: Set up Go
4242
uses: actions/setup-go@v4
4343
with:
44-
go-version: "1.22.5"
44+
go-version: "1.23.1"
4545
- name: Login to DockerHub
4646
uses: docker/login-action@v1
4747
with:

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v4
1919
with:
20-
go-version: "1.22.5"
20+
go-version: "1.23.1"
2121
- name: install dependencies
2222
run: go mod tidy
2323
- name: run unit tests
@@ -42,7 +42,7 @@ jobs:
4242
- name: Set up Go
4343
uses: actions/setup-go@v4
4444
with:
45-
go-version: "1.22.5"
45+
go-version: "1.23.1"
4646
- name: install dependencies
4747
run: go mod tidy
4848
- name: install spicedb binary
@@ -65,7 +65,7 @@ jobs:
6565
- name: Set up Go
6666
uses: actions/setup-go@v4
6767
with:
68-
go-version: "1.22.5"
68+
go-version: "1.23.1"
6969
- name: install dependencies
7070
run: go mod tidy
7171
- name: run regression tests

.golangci.yml

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
1-
run:
2-
timeout: 5m
3-
skip-dirs:
4-
- ui
1+
version: "2"
52
output:
6-
format: colored-line-number
3+
formats:
4+
text:
5+
path: stdout
76
linters:
8-
enable-all: false
9-
disable-all: true
7+
default: none
108
enable:
11-
- vet
12-
- goimports
13-
- thelper
14-
- unconvert
15-
- revive
16-
- unused
17-
- gofmt
18-
- whitespace
19-
- misspell
209
- govet
2110
- importas
22-
- protogetter
2311
- ineffassign
12+
- misspell
13+
- protogetter
14+
- revive
15+
- thelper
16+
- unconvert
17+
- unused
2418
- wastedassign
25-
# - gosec
26-
# - prealloc
27-
# - errcheck
28-
# - errorlint
29-
# - staticcheck
30-
# - gosimple
31-
# - gocritic
32-
# - goconst
33-
# - perfsprint
34-
linters-settings:
35-
revive:
36-
ignore-generated-header: true
37-
severity: warning
19+
- whitespace
20+
settings:
21+
revive:
22+
severity: warning
23+
exclusions:
24+
generated: lax
25+
presets:
26+
- comments
27+
- common-false-positives
28+
- legacy
29+
- std-error-handling
30+
paths:
31+
- third_party$
32+
- builtin$
33+
- examples$
3834
severity:
39-
default-severity: error
35+
default: error
36+
formatters:
37+
enable:
38+
- gofmt
39+
- goimports
40+
exclusions:
41+
generated: lax
42+
paths:
43+
- third_party$
44+
- builtin$
45+
- examples$

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ FROM alpine:3.18
22

33
COPY frontier /usr/bin/frontier
44

5-
ENTRYPOINT ["frontier"]
5+
ENTRYPOINT ["frontier"]

Dockerfile.dev

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ COPY Makefile .
88
RUN make ui
99

1010
# Build the Go binary
11-
FROM golang:1.22.3-alpine3.18 as builder
11+
FROM golang:1.23.1-alpine3.20 as builder
1212
RUN apk add --no-cache make
1313
WORKDIR /app
1414

@@ -27,4 +27,4 @@ RUN apk update && \
2727
apk add --no-cache ca-certificates libc6-compat && \
2828
rm -rf /var/cache/apk/*
2929

30-
ENTRYPOINT ["frontier"]
30+
ENTRYPOINT ["frontier"]

buf.gen.yaml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
---
2-
version: "v1"
2+
version: "v2"
3+
managed:
4+
enabled: true
5+
disable:
6+
- module: buf.build/googleapis/googleapis
7+
- module: buf.build/grpc-ecosystem/grpc-gateway
8+
- module: buf.build/envoyproxy/protoc-gen-validate
9+
override:
10+
- file_option: "go_package"
11+
value: "github.com/raystack/frontier/proto/v1beta1;frontierv1beta1"
312
plugins:
4-
- plugin: "buf.build/protocolbuffers/go:v1.30.0"
13+
- remote: "buf.build/protocolbuffers/go:v1.30.0"
514
out: "proto"
615
opt: "paths=source_relative"
7-
- plugin: "buf.build/grpc/go:v1.3.0"
16+
- remote: "buf.build/grpc/go:v1.3.0"
817
out: "proto"
918
opt: "paths=source_relative"
10-
- plugin: "buf.build/bufbuild/validate-go:v1.0.0"
19+
- remote: "buf.build/bufbuild/validate-go:v1.0.0"
1120
out: "proto"
1221
opt: "paths=source_relative"
13-
- plugin: "buf.build/grpc-ecosystem/gateway:v2.15.2"
22+
- remote: "buf.build/grpc-ecosystem/gateway:v2.15.2"
1423
out: "proto"
1524
opt: "paths=source_relative"
16-
- plugin: "buf.build/grpc-ecosystem/openapiv2:v2.16.0"
25+
- remote: "buf.build/grpc-ecosystem/openapiv2:v2.16.0"
1726
out: "proto"
1827
opt:
1928
- allow_merge=true
2029
- output_format=yaml
2130
- json_names_for_fields=false
31+
- remote: buf.build/connectrpc/go:v1.18.1
32+
out: "proto"
33+
opt: "paths=source_relative"

cmd/serve.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,14 @@ func StartServer(logger *log.Zap, cfg *config.Frontier) error {
305305

306306
go server.ServeUI(ctx, logger, cfg.UI, cfg.App)
307307

308-
// serving server
308+
// start connect server
309+
go func() {
310+
if err := server.ServeConnect(ctx, logger, cfg.App.Connect, deps); err != nil {
311+
logger.Fatal("connect server failed", "err", err.Error())
312+
}
313+
}()
314+
315+
// serving grpc server
309316
return server.Serve(ctx, logger, cfg.App, nrApp, deps, promRegistry)
310317
}
311318

config/sample.config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ app:
1717
port: 8000
1818
grpc:
1919
port: 8001
20+
connect:
21+
port: 8002
2022
# optional tls config
2123
# tls_cert_file: "temp/server-cert.pem"
2224
# tls_key_file: "temp/server-key.pem"

0 commit comments

Comments
 (0)