Skip to content

alpha: add public extensibility hooks for the gRPC server and CLI flags - #9742

Merged
matthewmcneely merged 1 commit into
mainfrom
oss-alpha-extensibility-hooks
Jun 19, 2026
Merged

matthewmcneely merged 1 commit into
mainfrom
oss-alpha-extensibility-hooks

Conversation

@matthewmcneely

@matthewmcneely matthewmcneely commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

What

Introduces dgraph/cmd/alpha/hooks.go, declaring package-level function vars with upstream-safe no-op defaults:

  • RegisterFlags(*pflag.FlagSet) — register extra CLI flags
  • RegisterZanzibar(*grpc.Server) — register an extra gRPC service
  • ZanzibarUnaryInterceptor() grpc.UnaryServerInterceptor / ZanzibarStreamInterceptor() grpc.StreamServerInterceptor — optional auth interceptors (returning nil = not installed)

In a stock build the defaults run, so behavior is unchanged.

It also refactors serveGRPC to build its interceptors as slices and install them via grpc.ChainUnaryInterceptor / grpc.ChainStreamInterceptor instead of a single grpc.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 to run.go — the same extension-hook pattern already used elsewhere in the tree.

@matthewmcneely
matthewmcneely requested a review from a team as a code owner June 11, 2026 18:52
@github-actions github-actions Bot added the go Pull requests that update Go code label Jun 11, 2026
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>
@matthewmcneely
matthewmcneely force-pushed the oss-alpha-extensibility-hooks branch from 2170980 to 0a4a22c Compare June 19, 2026 01:18
@matthewmcneely
matthewmcneely merged commit b2bbcdd into main Jun 19, 2026
18 checks passed
@matthewmcneely
matthewmcneely deleted the oss-alpha-extensibility-hooks branch June 19, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code

Development

Successfully merging this pull request may close these issues.

2 participants