Documentation ¶
Overview ¶
Package server is a package for protocol of a micro service
Index ¶
- Constants
- Variables
- func GetServers() map[string]ProtocolServer
- func Init() error
- func InstallPlugin(protocol string, newFunc NewFunc)
- func StartServer(options ...RunOption) error
- func UnRegistrySelfInstances() error
- type NewFunc
- type Options
- type ProtocolServer
- type RegisterOption
- type RegisterOptions
- type RunOption
- type RunOptions
Constants ¶
const ( DefaultMetricPath = "metrics" DefaultProfilePath = "profile" )
constants for server
Variables ¶
var ErrRuntime = make(chan error)
ErrRuntime is an error channel, if it receive any signal will cause graceful shutdown of go chassis, process will exit
Functions ¶
func InstallPlugin ¶
InstallPlugin For developer
func UnRegistrySelfInstances ¶
func UnRegistrySelfInstances() error
UnRegistrySelfInstances this function removes the self instance
Types ¶
type NewFunc ¶
type NewFunc func(Options) ProtocolServer
NewFunc returns a ProtocolServer
func GetServerFunc ¶
GetServerFunc returns the server function
type Options ¶
type Options struct { Address string ProtocolServerName string ChainName string Provider provider.Provider TLSConfig *tls.Config BodyLimit int64 HeaderLimit int Timeout time.Duration ProfilingEnable bool ProfilingAPI string MetricsEnable bool MetricsAPI string }
Options is the options for service initiating
type ProtocolServer ¶
type ProtocolServer interface { //Register a schema of microservice,return unique schema id,you can specify schema id and microservice name of this schema Register(interface{}, ...RegisterOption) (string, error) Start() error Stop() error String() string }
ProtocolServer interface for the protocol server, a server should implement init, register, start, and stop
func GetServer ¶
func GetServer(protocol string) (ProtocolServer, error)
GetServer return the server based on protocol
type RegisterOption ¶
type RegisterOption func(*RegisterOptions)
RegisterOption is option when you register a schema to chassis
func WithMethod ¶ added in v2.6.0
func WithMethod(Method string) RegisterOption
WithMethod specify a method
func WithPath ¶ added in v2.6.0
func WithPath(Path string) RegisterOption
WithPath specify a url pattern
func WithRPCServiceDesc ¶
func WithRPCServiceDesc(RPCSvcDesc interface{}) RegisterOption
WithRPCServiceDesc you can set rpc service desc, it cloud be *grpc.ServiceDesc
func WithSchemaID ¶
func WithSchemaID(schemaID string) RegisterOption
WithSchemaID you can specify a unique id for schema
type RegisterOptions ¶
RegisterOptions is options when you register a schema to chassis
type RunOption ¶ added in v2.7.0
type RunOption func(*RunOptions)
func WithServerMask ¶ added in v2.7.0
WithServerMask you can specify do not start a protocol server
type RunOptions ¶ added in v2.7.0
type RunOptions struct {
// contains filtered or unexported fields
}