Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate RPC to ConnectRPC #703

Merged
merged 33 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0fb6b27
Change protobuf configuration
krapie Oct 31, 2023
ea11372
Chnage yorkie rpc server to connect rpc server
krapie Oct 31, 2023
84a33a6
Change interceptors and helper
krapie Oct 31, 2023
7b37ddc
Update protobuf related codes
krapie Nov 2, 2023
60590f3
Update client codes
krapie Nov 2, 2023
83cf1ea
Update server test
krapie Nov 4, 2023
e177697
Update admin server codes
krapie Nov 28, 2023
afd02b6
Update go.mod for upstream sync
krapie Nov 28, 2023
8f35b11
Update rpc ports to http ports
krapie Nov 29, 2023
e30cf95
Update client & admin codes for bench test
krapie Dec 2, 2023
1eee993
Update secondary helper and interceptor
krapie Dec 2, 2023
31775d6
Update watch stream client codes
krapie Dec 2, 2023
2833375
Update client test
krapie Dec 2, 2023
75d29cc
Lint codes
krapie Dec 2, 2023
3329871
Update tests
krapie Dec 4, 2023
b2a6ff8
Update rpc server related tests
krapie Dec 7, 2023
1f22ad8
Revise client interceptor for streaming
krapie Dec 7, 2023
464e53f
Revise client mock test
krapie Dec 7, 2023
af64113
Refactor server init code
krapie Dec 10, 2023
3b4e3eb
Remove grpc-prometheus metrics & cleanup rpc server codes
krapie Dec 10, 2023
0381041
Add rpc server handled counter metrics
krapie Dec 11, 2023
c97c1bf
Update error detail logic
krapie Dec 11, 2023
f0a8011
Update client & server configuration
krapie Dec 11, 2023
5e631a6
Lint codes
krapie Dec 11, 2023
4f23378
Update tools
krapie Dec 11, 2023
1a38601
Revise CORS
krapie Dec 11, 2023
56fb0eb
Update overall codes
krapie Dec 12, 2023
c93f27f
Clean up converter
hackerwins Dec 13, 2023
b3bec3d
Revise server code and remove gRPC-related flags
hackerwins Dec 14, 2023
2f30459
Simplify converter interface
hackerwins Dec 15, 2023
26f7370
Change Client.Watch to wait initialization response
hackerwins Dec 15, 2023
025b5db
Recover missing headers from watch stream
hackerwins Dec 15, 2023
34795af
Revise codes
hackerwins Dec 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certifica
# Get and place binary to /bin
COPY --from=builder /app/bin/yorkie /bin/

# Expose port 11101, 11102 to the outside world
EXPOSE 11101 11102
# Expose port 8080, 8081 to the outside world
EXPOSE 8080 8081

# Define default entrypoint.
ENTRYPOINT ["yorkie"]
21 changes: 4 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,13 @@ GO_LDFLAGS += -X ${GO_PROJECT}/internal/version.BuildDate=${BUILD_DATE}
default: help

tools: ## install tools for developing yorkie
go install github.com/gogo/protobuf/protoc-gen-gogo@v1.3.2
go install github.com/gogo/protobuf/protoc-gen-gofast@v1.3.2
go install github.com/bufbuild/buf/cmd/buf@v1.28.1
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0
go install connectrpc.com/connect/cmd/protoc-gen-connect-go@v1.12.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.1

proto: ## generate proto files
protoc \
-I=./api \
-I=$(GOPATH)/src \
--gofast_out=plugins=grpc,\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,:./api/yorkie/v1 \
api/yorkie/v1/*.proto

protoset: ## generate protoset file
protoc \
-I=./api \
--descriptor_set_out=yorkie.protoset \
--include_imports \
api/yorkie/v1/*.proto
buf generate

build: ## builds an executable that runs in the current environment
CGO_ENABLED=0 go build -o $(EXECUTABLE) -ldflags "${GO_LDFLAGS}" ./cmd/yorkie
Expand Down
58 changes: 29 additions & 29 deletions admin/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ package admin
import (
"context"

"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"connectrpc.com/connect"

"github.com/yorkie-team/yorkie/api/types"
"github.com/yorkie-team/yorkie/internal/version"
Expand All @@ -43,39 +42,40 @@ func (i *AuthInterceptor) SetToken(token string) {
i.token = token
}

// Unary creates a unary server interceptor for authorization.
func (i *AuthInterceptor) Unary() grpc.UnaryClientInterceptor {
// WrapUnary creates a unary server interceptor for authorization.
func (i *AuthInterceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc {
return func(
ctx context.Context,
method string,
req,
reply interface{},
cc *grpc.ClientConn,
invoker grpc.UnaryInvoker,
opts ...grpc.CallOption,
) error {
ctx = metadata.AppendToOutgoingContext(ctx,
types.AuthorizationKey, i.token,
types.UserAgentKey, types.GoSDKType+"/"+version.Version,
)
return invoker(ctx, method, req, reply, cc, opts...)
req connect.AnyRequest,
) (connect.AnyResponse, error) {
req.Header().Add(types.AuthorizationKey, i.token)
req.Header().Add(types.UserAgentKey, types.GoSDKType+"/"+version.Version)

return next(ctx, req)
}
}

// WrapStreamingClient creates a stream client interceptor for authorization.
func (i *AuthInterceptor) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc {
return func(
ctx context.Context,
spec connect.Spec,
) connect.StreamingClientConn {
conn := next(ctx, spec)

conn.RequestHeader().Add(types.AuthorizationKey, i.token)
conn.RequestHeader().Add(types.UserAgentKey, types.GoSDKType+"/"+version.Version)

return conn
}
}

// Stream creates a stream server interceptor for authorization.
func (i *AuthInterceptor) Stream() grpc.StreamClientInterceptor {
// WrapStreamingHandler creates a stream server interceptor for authorization.
func (i *AuthInterceptor) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc {
return func(
ctx context.Context,
desc *grpc.StreamDesc,
cc *grpc.ClientConn,
method string,
streamer grpc.Streamer,
opts ...grpc.CallOption,
) (grpc.ClientStream, error) {
ctx = metadata.AppendToOutgoingContext(ctx,
types.AuthorizationKey, i.token,
types.UserAgentKey, types.GoSDKType+"/"+version.Version,
)
return streamer(ctx, desc, cc, method, opts...)
conn connect.StreamingHandlerConn,
) error {
return next(ctx, conn)
}
}
Loading
Loading