Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Duplex ¶
type Duplex struct { Server *grpc.Server MUX *runtime.ServeMux Loopback string Host string Port int DialOptions []grpc.DialOption }
Duplex is a wrapper for the gRPC server, gRPC HTTP Gateway MUX and options.
func New ¶
New creates a Duplex gRPC server / gRPC HTTP Gateway. New takes in options for `grpc.NewServer`, typed `grpc.ServerOption`, and `runtime.NewServeMux`, typed `runtime.ServeMuxOption`. Unknown opts will cause a panic.
func (*Duplex) ListenAndServe ¶
ListenAndServe starts both the gRPC server and HTTP Gateway MUX. Note: This call is blocking.
func (*Duplex) RegisterHandler ¶
func (d *Duplex) RegisterHandler(ctx context.Context, fn RegisterHandlerFromEndpointFn) error
RegisterHandler is a helper registration handler to call the passed in `RegisterHandlerFromEndpointFn` with the correct options after `d.Server` has been registered with the implementation. Use like: ```go
pb.Register<Type>Server(d.Server, impl.New<TypeImpl>()) if err := d.RegisterHandler(ctx, pb.Register<Type>HandlerFromEndpoint); err != nil { log.Panicf("Failed to register gateway endpoint: %v", err) }
```
func (*Duplex) RegisterListenAndServeMetrics ¶ added in v0.5.0
RegisterListenAndServe initializes Prometheus metrics and starts a HTTP /metrics endpoint for exporting Prometheus metrics in the background. Call this *after* all services have been registered.