Repository navigation
What's new in version 2
grpcreflect-go v2 is built for connect-go v2. The module path is now connectrpc.com/grpcreflect/v2. Reflection behavior, error codes, and wire compatibility with Google's gRPC implementations are unchanged. v1 is still supported for connect-go v1, and because the module paths differ, you can use both in the same module.
Reflection now registers on a connect.Server with one call that serves both the v1 and v1alpha APIs. By default it describes the services registered on the server, including the reflection services themselves, so the static service list usually goes away. Use WithNamer to list services yourself.
-reflector := grpcreflect.NewStaticReflector("acme.user.v1.UserService")
-mux.Handle(grpcreflect.NewHandlerV1(reflector))
-mux.Handle(grpcreflect.NewHandlerV1Alpha(reflector))
+connectServer := connect.NewServer()
+// Register your services on connectServer, then:
+grpcreflect.Register(connectServer)
+connecthttp.Mount(mux, connectServer)The client takes a *connect.Client. ClientStream.Close now returns only an error, and request and response metadata move from the stream to a connect.CallInfo on the context:
-client := grpcreflect.NewClient(httpClient, "https://api.example.com", connect.WithGRPC())
-stream := client.NewStream(ctx, grpcreflect.WithRequestHeaders(headers))
+client := grpcreflect.NewClient(connect.NewClient(connecthttp.NewTransport(
+ httpClient,
+ "https://api.example.com",
+ connecthttp.WithGRPC(),
+)))
+ctx, info := connect.NewClientContext(ctx)
+info.RequestHeader().Set("acme-tenant", "example")
+stream := client.NewStream(ctx)
names, err := stream.ListServices()
-trailers, err := stream.Close()
+err = stream.Close()
+trailers := info.ResponseTrailer()Namer, NamerFunc, ExtensionResolver, WithExtensionResolver, WithDescriptorResolver, and IsReflectionStreamBroken are unchanged. The v2 migration guide covers the change. The migration tool rewrites the client and Close, and flags the handler and reflector calls to replace with Register. See #99 for details.
To upgrade, run:
go get connectrpc.com/grpcreflect/v2@v2.0.0Full Changelog: v1.3.1...v2.0.0