server

package
Version: v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTLSConfig

func CreateTLSConfig(config Config, opts ...TLSConfigOption) (*tls.Config, error)

CreateTLSConfig will create a tls.Config given the config and options. This will return an error if there is a problem loading the required certificate files. If the WithMTLS option is specified, a client CA cert is required.

func Serve

func Serve(s Server) error

Serve starts the server and will catch os signals. If an os signal is caught, the server will be cancelled via it's the context.

Types

type Config

type Config interface {

	// Addr returns that network address the server listens to.
	Addr() string

	// Cert returns the file name of the PEM encoded public key.
	Cert() string

	// Key returns the file name of the PEM encoded private key.
	Key() string

	// CACert returns the file name of the PEM encoded public key of the client CA.
	CACert() string
}

Config contains the information necessary to create a server.

type Server

type Server interface {
	// Serve is the entry point for a service and will be run it a goroutine.
	// It is passed a channel to communicate the result.
	Serve(result chan<- error)

	// Stop stops the server.
	Stop()
}

Server abstracts a server.

type TLSConfigOption

type TLSConfigOption interface {
	// contains filtered or unexported methods
}

TLSConfigOption provides options for configuring the creation of a tls.Config.

func WithMTLS

func WithMTLS() TLSConfigOption

WithMTLS will setup the tls.Config to require and verify client connections.

Directories

Path Synopsis
mock
Package mockgrpc is a generated GoMock package.
Package mockgrpc is a generated GoMock package.
mock
Package mockhttp is a generated GoMock package.
Package mockhttp is a generated GoMock package.
Package mockserver is a generated GoMock package.
Package mockserver is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL