servicetoolset

package
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 32 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientAuthTypeMap added in v0.0.38

func ClientAuthTypeMap(ca ClientAuthType) tls.ClientAuthType

func GenClientTLSConfig

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

func GenServerTLSConfig

func GenServerTLSConfig(cfg *GRPCServerTLSConfig) (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 ClientAuthType added in v0.0.38

type ClientAuthType int
const (
	RequireAndVerifyClientCert ClientAuthType = iota
	NoClientCert
	RequestClientCert
	RequireAnyClientCert
	VerifyClientCertIfGiven
)

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 GRPCClientTLSConfig added in v0.0.38

type GRPCClientTLSConfig struct {
	DisableSystemPool  bool   `yaml:"DisableSystemPool" json:"disable_system_pool"`
	ServerName         string `yaml:"ServerName" json:"server_name"`
	InsecureSkipVerify bool   `yaml:"InsecureSkipVerify" json:"insecure_skip_verify"`

	RootCAs [][]byte `yaml:"RootCAs" json:"root_cas" `
	Cert    []byte   `yaml:"Cert" json:"cert"`
	Key     []byte   `yaml:"Key" json:"key"`
}

func GRPCClientTLSConfigMap added in v0.0.38

func GRPCClientTLSConfigMap(fileCfg *GRPCClientTLSFileConfig) (*GRPCClientTLSConfig, error)

type GRPCClientTLSFileConfig added in v0.0.38

type GRPCClientTLSFileConfig struct {
	DisableSystemPool  bool   `yaml:"DisableSystemPool" json:"disable_system_pool"`
	ServerName         string `yaml:"ServerName" json:"server_name"`
	InsecureSkipVerify bool   `yaml:"InsecureSkipVerify" json:"insecure_skip_verify"`

	RootCAs []string `yaml:"RootCAs" json:"root_cas" `
	Cert    string   `yaml:"Cert" json:"cert"`
	Key     string   `yaml:"Key" json:"key"`
}

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  *GRPCServerTLSConfig `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 GRPCServerTLSConfig added in v0.0.38

type GRPCServerTLSConfig struct {
	DisableSystemPool bool           `yaml:"DisableSystemPool" json:"disable_system_pool"`
	ClientAuth        ClientAuthType `yaml:"ClientAuth" json:"client_auth"`

	RootCAs [][]byte `yaml:"RootCAs" json:"root_cas" `
	Cert    []byte   `yaml:"Cert" json:"cert"`
	Key     []byte   `yaml:"Key" json:"key"`
}

func GRPCServerTLSConfigMap added in v0.0.38

func GRPCServerTLSConfigMap(fileCfg *GRPCServerTLSFileConfig) (*GRPCServerTLSConfig, error)

type GRPCServerTLSFileConfig added in v0.0.38

type GRPCServerTLSFileConfig struct {
	DisableSystemPool bool           `yaml:"DisableSystemPool" json:"disable_system_pool"`
	ClientAuth        ClientAuthType `yaml:"ClientAuth" json:"client_auth"`

	RootCAs []string `yaml:"RootCAs" json:"root_cas" `
	Cert    string   `yaml:"Cert" json:"cert"`
	Key     string   `yaml:"Key" json:"key"`
}

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