Documentation
¶
Index ¶
- Constants
- func Header(md *metadata.MD) grpc.CallOption
- func NewClient(nc *nats.Conn, opts ...ClientOption) grpc.ClientConnInterface
- func StreamHeaders(stream grpc.ClientStream) (metadata.MD, error)
- func StreamInterceptor(i grpc.StreamClientInterceptor) grpc.CallOption
- func TargetServerID(id string) grpc.CallOption
- func UnaryInterceptor(i grpc.UnaryClientInterceptor) grpc.CallOption
- type ClientOption
- func ClientChainStreamInterceptor(interceptors ...grpc.StreamClientInterceptor) ClientOption
- func ClientChainUnaryInterceptor(interceptors ...grpc.UnaryClientInterceptor) ClientOption
- func ClientStatsHandler(h stats.Handler) ClientOption
- func ClientStreamInterceptor(i grpc.StreamClientInterceptor) ClientOption
- func ClientToken(ts oauth2.TokenSource) ClientOption
- func ClientUnaryInterceptor(i grpc.UnaryClientInterceptor) ClientOption
- type Server
- type ServerOption
- func ServerChainStreamInterceptor(interceptors ...grpc.StreamServerInterceptor) ServerOption
- func ServerChainUnaryInterceptor(interceptors ...grpc.UnaryServerInterceptor) ServerOption
- func ServerContext(ctx context.Context) ServerOption
- func ServerID(id string) ServerOption
- func ServerStatsHandler(h stats.Handler) ServerOption
- func ServerStreamInterceptor(i grpc.StreamServerInterceptor) ServerOption
- func ServerUnaryInterceptor(i grpc.UnaryServerInterceptor) ServerOption
- func ServerVersion(v string) ServerOption
Constants ¶
const ( MetadataServiceName = "X-Google-RPC-Service-Name" MetadataServiceMetadata = "X-Google-RPC-Service-Metadata" HeaderMethodName = "X-Google-RPC-Method-Name" HeaderMethodPath = "X-Google-RPC-Method-Path" HeaderStreamName = "X-Google-RPC-Stream-Name" HeaderStreamPath = "X-Google-RPC-Stream-Path" HeaderAuthorization = "Authorization" )
Variables ¶
This section is empty.
Functions ¶
func Header ¶
func Header(md *metadata.MD) grpc.CallOption
Header returns a grpc.CallOption that sets the metadata headers.
This is used to capture the response headers from a gRPC call.
func NewClient ¶
func NewClient(nc *nats.Conn, opts ...ClientOption) grpc.ClientConnInterface
NewClient creates a new grpc.ClientConnInterface with the provided NATS connection and optional options
func StreamHeaders ¶
func StreamHeaders(stream grpc.ClientStream) (metadata.MD, error)
StreamHeaders returns the headers from a gRPC stream.
This is used to capture the response headers from a gRPC stream.
func StreamInterceptor ¶
func StreamInterceptor(i grpc.StreamClientInterceptor) grpc.CallOption
StreamInterceptor returns a grpc.CallOption that sets the stream interceptor.
This interceptor will be called after the other client interceptors are called.
func TargetServerID ¶
func TargetServerID(id string) grpc.CallOption
TargetServerID returns a grpc.CallOption that sets the target server ID.
This is specifically for calling a single service that has the `ngrpc.ServerID` option set.
func UnaryInterceptor ¶
func UnaryInterceptor(i grpc.UnaryClientInterceptor) grpc.CallOption
UnaryInterceptor returns a grpc.CallOption that sets the unary interceptor.
This interceptor will be called after the other client interceptors are called.
Types ¶
type ClientOption ¶
type ClientOption func(*client)
ClientOption to configure the ngrpc.Client
func ClientChainStreamInterceptor ¶
func ClientChainStreamInterceptor(interceptors ...grpc.StreamClientInterceptor) ClientOption
func ClientChainUnaryInterceptor ¶
func ClientChainUnaryInterceptor(interceptors ...grpc.UnaryClientInterceptor) ClientOption
func ClientStatsHandler ¶
func ClientStatsHandler(h stats.Handler) ClientOption
ClientStatsHandler sets the stats handler for the client
func ClientStreamInterceptor ¶
func ClientStreamInterceptor(i grpc.StreamClientInterceptor) ClientOption
func ClientToken ¶
func ClientToken(ts oauth2.TokenSource) ClientOption
ClientToken sets the Authorization for the client and will be applied to every RPC call
func ClientUnaryInterceptor ¶
func ClientUnaryInterceptor(i grpc.UnaryClientInterceptor) ClientOption
type Server ¶
type Server interface { grpc.ServiceRegistrar // Stop and drain all services Stop() error }
Server compatible with grpc.ServiceRegister for generated gRPC services over NATS connections. ClientStreams are NOT supported and will PANIC if registered.
func NewServer ¶
func NewServer(nc *nats.Conn, opts ...ServerOption) Server
NewServer create a new gRPC server that uses NATS as the transport
type ServerOption ¶
type ServerOption func(*server)
ServerOption to configure the ngrpc.Server
func ServerChainStreamInterceptor ¶
func ServerChainStreamInterceptor(interceptors ...grpc.StreamServerInterceptor) ServerOption
ServerChainStreamInterceptor returns a ServerOption that specifies the chained interceptor for streaming RPCs. The first interceptor will be the outer most, while the last interceptor will be the inner most wrapper around the real call. All stream interceptors added by this method will be chained.
func ServerChainUnaryInterceptor ¶
func ServerChainUnaryInterceptor(interceptors ...grpc.UnaryServerInterceptor) ServerOption
ServerChainUnaryInterceptor returns a ServerOption that specifies the chained interceptor for unary RPCs. The first interceptor will be the outer most, while the last interceptor will be the inner most wrapper around the real call. All unary interceptors added by this method will be chained.
func ServerContext ¶
func ServerContext(ctx context.Context) ServerOption
ServerContext sets the base context for the server and all incoming requests
func ServerID ¶
func ServerID(id string) ServerOption
ServerID sets the server ID. This will isolate the server from other servers and can only be called directly.
func ServerStatsHandler ¶
func ServerStatsHandler(h stats.Handler) ServerOption
ServerStatsHandler sets the stats handler for the server
func ServerStreamInterceptor ¶
func ServerStreamInterceptor(i grpc.StreamServerInterceptor) ServerOption
ServerStreamInterceptor returns a ServerOption that sets the StreamServerInterceptor for the server. Only one stream interceptor can be installed.
func ServerUnaryInterceptor ¶
func ServerUnaryInterceptor(i grpc.UnaryServerInterceptor) ServerOption
ServerUnaryInterceptor returns a ServerOption that sets the UnaryServerInterceptor for the server. Only one unary interceptor can be installed. The construction of multiple interceptors (e.g., chaining) can be implemented at the caller.
func ServerVersion ¶
func ServerVersion(v string) ServerOption
ServerVersion sets the server version of the NATS micro services