server

package
v2.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 17 Imported by: 22

Documentation

Overview

Package server is a package for protocol of a micro service

Index

Constants

View Source
const (
	DefaultMetricPath  = "metrics"
	DefaultProfilePath = "profile"
)

constants for server

Variables

View Source
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 GetServers

func GetServers() map[string]ProtocolServer

GetServers returns the map of servers

func Init

func Init() error

Init initializes

func InstallPlugin

func InstallPlugin(protocol string, newFunc NewFunc)

InstallPlugin For developer

func StartServer

func StartServer(options ...RunOption) error

StartServer starting the server

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

func GetServerFunc(protocol string) (NewFunc, error)

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

type RegisterOptions struct {
	SchemaID   string
	Method     string
	Path       string
	RPCSvcDesc interface{}
}

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

func WithServerMask(serverNames ...string) RunOption

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
}

Jump to

Keyboard shortcuts

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