package
0.0.0-20210210154335-f4159b9fcd5f
Repository: https://github.com/digital-dream-labs/hugh.git
Documentation: pkg.go.dev
# README
Client
To quickly get a grpc connection (in this example, with non-system TLS certs) you'd simply do this:
Note: this example uses the grpc example protobufs
func getconn() echo.EchoClient {
cli, err := New(
WithCertPool(tls.LocalhostTLSConfig().RootCAs),
WithTarget("hostame:1234")
)
if err != nil {
log.Fatal(err)
}
err := cli.Connect(); err != nil {
log.Fatal(err)
}
return echo.NewEchoClient(cli.Conn())
}
This expects the following environment variables to be in place when calling WithViper() without arguments
Environment Variable | Description |
---|---|
DDL_RPC_TARGET | Sets the target host for an RPC client |
DDL_RPC_TLS_CERTIFICATE | Sets the client authentication cert for mutual tls |
DDL_RPC_KEY | Private key that pairs with tls certificate |
DDL_RPC_TLS_CA | Sets the certificate authority for client verification |
DDL_RPC_APP_KEY | populates the RPC context with an app key |
A full list of options can be found in options.go
# Functions
New creates a client.
WithCertificate adds certs for authentication.
WithCertPool overrides the system CA pool.
WithClientAuth sets the tls ClientAuthType to control auth behavior.
WithDialopts adds dial options.
WithDisableTLS turns off tls.
WithInsecureSkipVerify makes connections not that safe to use.
WithLogger set the log instance for client and server instances.
WithStreamClientInterceptors sets the streaming client middleware.
WithTarget sets the target host.
WithUnaryClientInterceptors sets the unary client middleware.
WithViper specifies that the client or server should construct its options using viper.
# Constants
EnvironmentPrefix sets the prefix to strip from environment variables when resolving keys.
EnvironmentReplace takes a comma separated list of old,new.
# Type aliases
Option provides a function definition to set options.