-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add grpc channel registry #13
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
Conversation
public class GrpcChannelRegistry { | ||
private static final Logger LOG = LoggerFactory.getLogger(GrpcChannelRegistry.class); | ||
private final Map<String, ManagedChannel> channelMap = new ConcurrentHashMap<>(); | ||
private volatile boolean isShutdown = false; |
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.
Removed the integrated shutdown on this one so it didn't bring in more dependencies (the shutdown lifecycle is from), but I can bring it back if that seems more useful. The more I think on it, the more I think I'll optionally add just the future part of it (to avoid the dependency)
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.
Changed my mind again - the difference of accepting a hook is really just the below anyway:
new GrpcChannelRegistry(future);
// vs
registry = new GrpcChannelRegistry();
future.thenRun(registry::shutdown);
This comment has been minimized.
This comment has been minimized.
Codecov Report
@@ Coverage Diff @@
## main #13 +/- ##
============================================
+ Coverage 64.96% 66.47% +1.50%
- Complexity 51 58 +7
============================================
Files 13 14 +1
Lines 157 170 +13
Branches 9 9
============================================
+ Hits 102 113 +11
Misses 49 49
- Partials 6 8 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Description
This channel registry, ported from https://github.com/hypertrace/hypertrace-core-graphql/blob/7df21a96bf0712e239ced1117c49889870cf7b3e/hypertrace-core-graphql-grpc-utils/src/main/java/org/hypertrace/core/graphql/utils/grpc/DefaultGrpcChannelRegistry.java is used by clients to prevent multiple places in code from instantiating the same channel (which grpc strongly discourages), instead sharing channels and allowing centralized shutdown.
Testing
Added UT
Checklist: