-
Notifications
You must be signed in to change notification settings - Fork 109
chore: optimize grpc #1363
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
chore: optimize grpc #1363
Conversation
|
|
||
| // Configure your client host and interceptors. | ||
| // Interceptors can be the group name of UnaryClientInterceptorGroups in app/grpc/kernel.go. | ||
| "clients": map[string]any{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's incorrect before. It's actually servers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 1 comment
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1363 +/- ##
=======================================
Coverage 70.00% 70.01%
=======================================
Files 284 284
Lines 17714 17716 +2
=======================================
+ Hits 12401 12403 +2
Misses 4777 4777
Partials 536 536 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, 1 comment
Greptile Overview
Greptile Summary
Refactored gRPC client configuration naming from
clientstoserversto better reflect semantic meaning - the configuration describes gRPC servers that the client connects to, not multiple clients.Key changes:
Connect(server string)method to replaceClient(ctx, name)- removes unusedctxparameter and renamesnametoserverfor clarityClientmethod with v1.18 removal noticeclients maptoservers mapwith updated mutex commentgrpc.clients.*togrpc.servers.*apptorfor consistencyConnectmethodThe refactoring maintains backward compatibility through the deprecated
Clientmethod which delegates toConnect.Confidence Score: 5/5
Important Files Changed
Connectmethod and deprecatedClientmethod; comment typo foundclientstoservers, deprecatedClientin favor ofConnect, updated config paths fromgrpc.clients.*togrpc.servers.*grpc.servers.*instead ofgrpc.clients.*serversinstead ofclientswith clearer documentationConnectmethodSequence Diagram
sequenceDiagram participant Client as Client Code participant App as Application participant Config as Config participant Cache as servers map participant GRPC as gRPC Server Note over Client,App: Old API (Deprecated) Client->>App: Client(ctx, name) App->>App: Connect(name) Note over Client,GRPC: New API Client->>App: Connect(server) App->>Cache: Check cached connection (RLock) alt Connection exists and healthy Cache-->>App: Return cached conn App-->>Client: Return connection else No connection or shutdown App->>Cache: Acquire write lock App->>Cache: Double-check pattern alt Still needs creation App->>Config: GetString("grpc.servers.{server}.host") Config-->>App: host App->>Config: Get("grpc.servers.{server}.interceptors") Config-->>App: interceptor keys App->>Config: Get("grpc.servers.{server}.stats_handlers") Config-->>App: stats handler keys App->>GRPC: grpc.NewClient(host, dialOpts) GRPC-->>App: newConn App->>Cache: Store connection Cache-->>App: Connection stored App-->>Client: Return new connection else Created by another goroutine Cache-->>App: Return existing conn App-->>Client: Return connection end end