alpha: add public extensibility hooks for the gRPC server and CLI flags#9742
Open
matthewmcneely wants to merge 1 commit into
Open
alpha: add public extensibility hooks for the gRPC server and CLI flags#9742matthewmcneely wants to merge 1 commit into
matthewmcneely wants to merge 1 commit into
Conversation
Introduce dgraph/cmd/alpha/hooks.go declaring package-level function vars with upstream-safe no-op defaults: RegisterFlags(*pflag.FlagSet), RegisterZanzibar(*grpc.Server), and ZanzibarUnary/StreamInterceptor() returning nil. In a stock build the defaults run, so behavior is unchanged. Refactor serveGRPC to build its interceptors as slices and install them via grpc.ChainUnaryInterceptor / grpc.ChainStreamInterceptor instead of a single grpc.UnaryInterceptor. The audit interceptor stays first; the chain lets additional unary/stream interceptors compose. Wire RegisterFlags(flag) into Alpha's flag setup and RegisterZanzibar(s) into the server registration. These are extension points: a build can register an extra gRPC service, CLI flags, and auth interceptors by reassigning the vars from its own init(), with no further changes to run.go. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Introduces
dgraph/cmd/alpha/hooks.go, declaring package-level function vars with upstream-safe no-op defaults:RegisterFlags(*pflag.FlagSet)— register extra CLI flagsRegisterZanzibar(*grpc.Server)— register an extra gRPC serviceZanzibarUnaryInterceptor() grpc.UnaryServerInterceptor/ZanzibarStreamInterceptor() grpc.StreamServerInterceptor— optional auth interceptors (returningnil= not installed)In a stock build the defaults run, so behavior is unchanged.
It also refactors
serveGRPCto build its interceptors as slices and install them viagrpc.ChainUnaryInterceptor/grpc.ChainStreamInterceptorinstead of a singlegrpc.UnaryInterceptor, so multiple interceptors can compose. The audit interceptor stays first.Why
Lets a build register an extra gRPC service, CLI flags, and auth interceptors by reassigning the vars from its own
init(), with no further changes torun.go— the same extension-hook pattern already used elsewhere in the tree.Notes for review
Zanzibar). I'm happy to rename to neutral terms (e.g.RegisterExtraService/ServiceUnaryInterceptor) if you'd prefer the public surface not name a specific consumer.hooks.gocarries an Apache-2.0 header attributed to the downstream author where the file originated. Flag if you'd rather it use the standard project header.