package
0.0.0-20210210154335-f4159b9fcd5f
Repository: https://github.com/digital-dream-labs/hugh.git
Documentation: pkg.go.dev

# README

Server

To quickly get a grpc server (in this example, with non-system TLS certs) you'd simply do this:

Note: this example uses the grpc example protobufs

func startTestServer() error {
    srv, err := server.New(
        server.WithCertificate(tls.LocalhostTLSConfig().Certificates[0]),
    )
    if err != nil {
        return err
    }

    echosrv := grpc.New()

    echo.RegisterEchoServer(
        srv.Transport(),
        echosrv,
    )

    srv.Start()
    <-srv.Notify(server.Ready)
    return nil
}

This expects the following environment variables to be in place when calling WithViper() without arguments

Environment VariableDescriptionDefault
DDL_RPC_CLIENT_AUTHENTICATIONValues: [NoClientCert, RequestClientCert, RequireAnyClientCert, VerifyClientCertIfGiven, RequireAndVerifyClientCert]NoClientCert
DDL_RPC_TLS_CERTIFICATESets the certificate to use for transport encryption
DDL_RPC_KEYPrivate key that pairs with tls certificate
DDL_RPC_TLS_CALoad a custom CA pool instead of using the system CAempty
DDL_RPC_PORTSets the listener port.0
DDL_RPC_TLS_CASets the certificate authority for client verificationempty
DDL_RPC_INSECUREdisable TLS verificationfalse

A full list of options can be found in options.go

# Functions

New constructs a new Server.
WithCertificate specifies the certificates that will be appended to the tls.Config.
WithCertPool overrides the system cert pool.
WithClientAuth sets the tls ClientAuthType to control auth behavior.
WithHTTPPassthrough starts an additional HTTP passthrough for rest operations.
WithHTTPPassthroughInsecure enables an insecure http passthrough.
WithInsecureSkipVerify makes connections not that safe to use.
WithLogger set the log instance.
WithPort sets the listener port.
WithReflectionService starts a reflection service capable to describing services.
WithStreamServerInterceptors sets the streaming middleware.
WithTLSCert statically sets a TLS certificate.
WithTLSKey statically sets a TLS key.
WithUnaryServerInterceptors sets the unary middleware.
WithViper specifies that the 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.
Error means the connection is in error.
Init is a new connection.
Ready means the connection is ready.
Starting means the connection is starting.
Stopped means the connection is stopping.
Stopping means the connection is being shut down.

# Structs

Server is a server struct.

# Type aliases

Option provides a function definition to set options.
State tracks the state of the connection.