servicetoolset

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 30 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenClientTLSConfig

func GenClientTLSConfig(cfg *GRPCTlsConfig) (tlsConfig *tls.Config, err error)

func GenServerTLSConfig

func GenServerTLSConfig(cfg *GRPCTlsConfig) (tlsConfig *tls.Config, err error)

func GetDiscoveryHostAndPort added in v0.0.22

func GetDiscoveryHostAndPort(externalAddress, listeningAddress string) (host string, port int, err error)

func NewGRPCWebHandler

func NewGRPCWebHandler(parameters GRPCWebHandlerInputParameters) (http.Handler, error)

func SignalContext

func SignalContext(ctx context.Context, logger l.Wrapper) context.Context

Types

type AbstractServer

type AbstractServer interface {
	Run(ctx context.Context) error
}

type BeforeServerStart

type BeforeServerStart func(server *grpc.Server) error

type DiscoveryExConfig

type DiscoveryExConfig struct {
	Setter          discovery.Setter  `json:"-" yaml:"-" ignored:"true"`
	ExternalAddress string            `yaml:"external_address" json:"external_address"`
	Meta            map[string]string `yaml:"meta" json:"meta"`
}

type GRPCServer

type GRPCServer interface {
	Start(init BeforeServerStart) (err error)
	Wait()
	Stop()
	StopAndWait()

	Run(ctx context.Context) (err error)
}

func NewGRPCServer

func NewGRPCServer(routineMan routineman.RoutineMan, cfg *GRPCServerConfig, opts []grpc.ServerOption,
	defInit BeforeServerStart, logger l.Wrapper, extraInterceptors ...interface{}) (GRPCServer, error)

type GRPCServerConfig

type GRPCServerConfig struct {
	Address    string         `yaml:"address" json:"address"`
	TLSConfig  *GRPCTlsConfig `yaml:"tls_config" json:"tls_config"`
	WebAddress string         `yaml:"web_address" json:"web_address"`

	Name              string             `yaml:"name" json:"name"`
	MetaTransKeys     []string           `yaml:"meta_trans_keys" json:"meta_trans_keys"`
	DiscoveryExConfig *DiscoveryExConfig `yaml:"discovery_ex_config" json:"discovery_ex_config"`

	KeepAliveDuration        time.Duration `yaml:"keep_alive_duration" json:"keep_alive_duration"`
	EnforcementPolicyMinTime time.Duration `yaml:"enforcement_policy_min_time" json:"enforcement_policy_min_time"`
}

type GRPCTlsConfig

type GRPCTlsConfig struct {
	RootCAs            [][]byte `yaml:"RootCAs" json:"root_cas" `
	Cert               []byte   `yaml:"Cert" json:"cert"`
	Key                []byte   `yaml:"Key" json:"key"`
	ServerName         string   `yaml:"ServerName" json:"server_name"`
	InsecureSkipVerify bool     `yaml:"InsecureSkipVerify" json:"insecure_skip_verify"`
}

func GRPCTlsConfigMap

func GRPCTlsConfigMap(fileCfg *GRPCTlsFileConfig) (*GRPCTlsConfig, error)

type GRPCTlsFileConfig

type GRPCTlsFileConfig struct {
	RootCAs            []string `yaml:"RootCAs" json:"root_cas" `
	Cert               string   `yaml:"Cert" json:"cert"`
	Key                string   `yaml:"Key" json:"key"`
	ServerName         string   `yaml:"ServerName" json:"server_name"`
	InsecureSkipVerify bool     `yaml:"InsecureSkipVerify" json:"insecure_skip_verify"`
}

type GRPCWebHandlerInputParameters

type GRPCWebHandlerInputParameters struct {
	GRPCServer          *grpc.Server
	GRPCWebUseWebsocket bool
	GRPCWebPingInterval time.Duration
}

type HTTPServer

type HTTPServer interface {
	Run(ctx context.Context) (err error)
}

func NewHTTPServer

func NewHTTPServer(name, address string, handler http.Handler, discoveryExConfig *DiscoveryExConfig, logger l.Wrapper) HTTPServer

type HTTPServerConfig added in v0.0.18

type HTTPServerConfig struct {
	Name              string            `yaml:"name" json:"name"`
	Address           string            `yaml:"address" json:"address"`
	Handler           http.Handler      `json:"-" yaml:"-"`
	DiscoveryExConfig DiscoveryExConfig `yaml:"discovery_ex_config" json:"discovery_ex_config"`
}

type ServerHelper

type ServerHelper struct {
	// contains filtered or unexported fields
}

func NewServerHelper

func NewServerHelper(ctx context.Context, logger l.Wrapper) *ServerHelper

func (*ServerHelper) StartServer

func (sh *ServerHelper) StartServer(s AbstractServer)

func (*ServerHelper) Wait

func (sh *ServerHelper) Wait()

type ServerToolset

type ServerToolset struct {
	// contains filtered or unexported fields
}

func NewServerToolset

func NewServerToolset(ctx context.Context, logger l.Wrapper) *ServerToolset

func (*ServerToolset) CreateGRpcServer

func (st *ServerToolset) CreateGRpcServer(cfg *GRPCServerConfig, opts []grpc.ServerOption, beforeServerStart BeforeServerStart) (err error)

func (*ServerToolset) CreateHTTPServer added in v0.0.18

func (st *ServerToolset) CreateHTTPServer(cfg *HTTPServerConfig) error

func (*ServerToolset) Start

func (st *ServerToolset) Start() error

func (*ServerToolset) Wait

func (st *ServerToolset) Wait()

Jump to

Keyboard shortcuts

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