Documentation ¶
Overview ¶
Package grpc provides a Connection implementation. It can be used to interact with GRPC services, hosted in secure or insecure environments.
It aims to simplify the connection setup phase.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface { Client() *grpc.ClientConn Close() error AuthenticateContext(context.Context) (context.Context, error) }
Connection is an helper, that holds the actual grpc.ClientConn connection. It encapsulate the authentication, and the setup of the transport credentials.
func NewConnection ¶
func NewConnection(opt ConnectionOptions) (Connection, error)
NewConnection builds a new GRPC connection object. It holds the actual grpc.ClientConn used to interact with a GRPC service. It also provides an helper method to authenticate a context.
The isInsecure parameter is used to set on/off the security context:
- if true, the token source is unset, and the transport credentials are empty.
- else, the token source is configured, and and the transport credentials use TLS.
The host is used to setup the grpc.ClientConn.
type ConnectionOptions ¶
type ConnectionOptions struct { // Target build parameter Target string // Insecure builder parameter Insecure bool // Custom provider which provides a token source and a GRPC client // connection Provider Provider }
ConnectionOptions holds the parameters for the Connection builder
type Provider ¶
type Provider interface { // NewTokenSource builds a new token source instance. NewTokenSource(audience string, insecure bool) (TokenSource, error) // NewClient builds a new GRPC client connection NewClient(target string, insecure bool) (*grpc.ClientConn, error) }
Provider is responsible to provide new instances of:
- a new GRPC client connection
- a new token source
type TokenSource ¶
TokenSource is responsible for providing OAuth tokens