Documentation ¶
Overview ¶
Package avaiation is a collection of tools to support grpc middleware
Index ¶
- func ChainStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.StreamServerInterceptor
- func ChainUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor
- func Dial(ctx context.Context, opts DialOptions) (*grpc.ClientConn, error)
- func GetCACertPool(cas ...[]byte) (*x509.CertPool, error)
- func GetClientTLSConfig(cas [][]byte, crt, key []byte) (*tls.Config, error)
- func GetClientTLSConfigFromFiles(caFiles []string, crtFile, keyFile string) (*tls.Config, error)
- func GetRequestID(ctx context.Context) int
- func GetRequestStartAt(ctx context.Context) time.Time
- func GetUser(ctx context.Context) gimlet.User
- func MakeAuthenticationRequiredStreamInterceptor(um gimlet.UserManager, conf gimlet.UserMiddlewareConfiguration, ...) grpc.StreamServerInterceptor
- func MakeAuthenticationRequiredUnaryInterceptor(um gimlet.UserManager, conf gimlet.UserMiddlewareConfiguration, ...) grpc.UnaryServerInterceptor
- func MakeCertificateUserValidationStreamInterceptor(um gimlet.UserManager) grpc.StreamServerInterceptor
- func MakeCertificateUserValidationUnaryInterceptor(um gimlet.UserManager) grpc.UnaryServerInterceptor
- func MakeConditionalGripStreamInterceptor(logger grip.Journaler, when func() bool) grpc.StreamServerInterceptor
- func MakeConditionalGripUnaryInterceptor(logger grip.Journaler, when func() bool) grpc.UnaryServerInterceptor
- func MakeGripStreamInterceptor(logger grip.Journaler) grpc.StreamServerInterceptor
- func MakeGripUnaryInterceptor(logger grip.Journaler) grpc.UnaryServerInterceptor
- func MakeRetryStreamClientInterceptor(maxRetries int) grpc.StreamClientInterceptor
- func MakeRetryUnaryClientInterceptor(maxRetries int) grpc.UnaryClientInterceptor
- func SetRequestID(ctx context.Context, id int) context.Context
- func SetRequestStartAt(ctx context.Context, startAt time.Time) context.Context
- func SetRequestUser(ctx context.Context, u gimlet.User) context.Context
- type DialOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChainStreamServer ¶
func ChainStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.StreamServerInterceptor
ChainStreamServer creates a single interceptor out of a chain of many interceptors.
Execution is done in left-to-right order, including passing of context. For example ChainUnaryServer(one, two, three) will execute one before two before three. If you want to pass context between interceptors, use WrapServerStream.
Implementation from https://github.com/grpc-ecosystem/go-grpc-middleware/blob/master/chain.go
func ChainUnaryServer ¶
func ChainUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor
ChainUnaryServer creates a single interceptor out of a chain of many interceptors.
Execution is done in left-to-right order, including passing of context. For example ChainUnaryServer(one, two, three) will execute one before two before three, and three will see context changes of one and two.
Implementation from https://github.com/grpc-ecosystem/go-grpc-middleware/blob/master/chain.go
func Dial ¶
func Dial(ctx context.Context, opts DialOptions) (*grpc.ClientConn, error)
Dial creates a client connection to a RPC service via gRPC.
func GetCACertPool ¶
GetCACertPool is a convenience function that creates a cert pool with the given cas and, when possible, the system cert pool. On windows machines, the cert pool will be empty if no cas are passed in.
func GetClientTLSConfig ¶
GetClientTLSConfig creates a creates a client-side TLS configuration based on the given cas, cert, and key. If possible, the system cert pool is combined with the provided cas.
func GetClientTLSConfigFromFiles ¶
GetClientTLSConfigFromFiles creates a creates a client-side TLS configuration based on the given ca, cert, and key files.
func GetRequestID ¶
GetRequestID returns the unique (monotonically increaseing) ID of the request since startup
func MakeAuthenticationRequiredStreamInterceptor ¶
func MakeAuthenticationRequiredStreamInterceptor(um gimlet.UserManager, conf gimlet.UserMiddlewareConfiguration, ignore ...string) grpc.StreamServerInterceptor
func MakeAuthenticationRequiredUnaryInterceptor ¶
func MakeAuthenticationRequiredUnaryInterceptor(um gimlet.UserManager, conf gimlet.UserMiddlewareConfiguration, ignore ...string) grpc.UnaryServerInterceptor
func MakeCertificateUserValidationStreamInterceptor ¶
func MakeCertificateUserValidationStreamInterceptor(um gimlet.UserManager) grpc.StreamServerInterceptor
Return a gRPC UnaryStreamInterceptor which checks the certifcate user's validity against the given user manager.
func MakeCertificateUserValidationUnaryInterceptor ¶
func MakeCertificateUserValidationUnaryInterceptor(um gimlet.UserManager) grpc.UnaryServerInterceptor
Return a gRPC UnaryServerInterceptor which checks the certifcate user's validity against the given user manager.
func MakeConditionalGripStreamInterceptor ¶
func MakeConditionalGripStreamInterceptor(logger grip.Journaler, when func() bool) grpc.StreamServerInterceptor
func MakeConditionalGripUnaryInterceptor ¶
func MakeConditionalGripUnaryInterceptor(logger grip.Journaler, when func() bool) grpc.UnaryServerInterceptor
func MakeGripStreamInterceptor ¶
func MakeGripStreamInterceptor(logger grip.Journaler) grpc.StreamServerInterceptor
func MakeGripUnaryInterceptor ¶
func MakeGripUnaryInterceptor(logger grip.Journaler) grpc.UnaryServerInterceptor
func MakeRetryStreamClientInterceptor ¶
func MakeRetryStreamClientInterceptor(maxRetries int) grpc.StreamClientInterceptor
func MakeRetryUnaryClientInterceptor ¶
func MakeRetryUnaryClientInterceptor(maxRetries int) grpc.UnaryClientInterceptor
func SetRequestID ¶
SetRequesID attaches a request id to a context.
func SetRequestStartAt ¶
Types ¶
type DialOptions ¶
type DialOptions struct { // Address is the RPC address to connect to. Address string // Retries specifies the number of times the client connection retries // an operation before failing. Retries int // TLSConf is the config for TLS authentication. If TLSConf is // specified, CAFile, CrtFile, and KeyFile are ignored. If neither // TLSFile nor the certificate files are specified, the connection is // created without TLS. (Optional) TLSConf *tls.Config // CAFiles are the names of the file with the CA certificates for TLS. // If specified, CrtFile and KeyFile must also be specified. (Optional) CAFiles []string // CrtFile is the name of the file with the user certificate for TLS. // If specified, CAFiles and KeyFile must also be specified. (Optional) CrtFile string // KeyFile is the name of the file with the key certificate for TLS. If // specified, CAFiles and CrtFile must also be specified. (Optional) KeyFile string // Username is the username of the API user. If specified, APIKey must // also be specified. (Optional) Username string // APIKey is the API key for user authentication. If specified, // Username must also be specified. (Optional) APIKey string // APIUserHeader is the metadata key for the requester's username. This // must be specified if Username and APIKey are specified. (Optional) APIUserHeader string // APIKeyHeader is the metadata key for the requester's API key. This // must be specified if Username and APIKey are specified. (Optional) APIKeyHeader string }
DialOptions describes the options for creating a client connection to a RPC service via gRPC.