server

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDispatcher = NewDispatcher()
View Source
var NewDispatcher = func() *dispatcher {
	return &dispatcher{
		serviceMap: make(map[string]Service),
	}
}

Functions

This section is empty.

Types

type FilterFunc

type FilterFunc func(ctx context.Context, srv interface{}, parse func(interface{}) error,
	handlers []interceptor.ServerHandler) (rep interface{}, err error)

type Method

type Method struct {
	Name string
	Func FilterFunc
}

type Option

type Option func(*Options)

func WithAddress

func WithAddress(addr string) Option

func WithAfterHandle

func WithAfterHandle(iter ...interceptor.ServerHandler) Option

func WithBeforeHandle

func WithBeforeHandle(iter ...interceptor.ServerHandler) Option

func WithCodecType

func WithCodecType(codecType string) Option

func WithKeepAlivePeriod

func WithKeepAlivePeriod(t time.Duration) Option

func WithNetWork

func WithNetWork(network string) Option

func WithPluginFactory

func WithPluginFactory(p *plugin.Factory) Option

func WithPluginFactoryOptions

func WithPluginFactoryOptions(o []plugin.Option) Option

func WithPort

func WithPort(port string) Option

func WithSerializerType

func WithSerializerType(serializerType string) Option

func WithServerName

func WithServerName(name string) Option

type Options

type Options struct {
	ServerName           string        `yaml:"name"`
	Port                 string        `yaml:"port"`
	Network              string        `yaml:"network"`
	KeepAlivePeriod      time.Duration `yaml:"keep_alive_period"`
	SerializerType       string        `yaml:"serializer"`
	CodecType            string        `yaml:"codec"`
	CompressType         string        `yaml:"compress"`
	Address              string
	PluginFactoryOptions []plugin.Option
	PluginFactory        *plugin.Factory
	// contains filtered or unexported fields
}

type Server

type Server struct {
	Options    *Options
	ServiceMap map[string]Service
}
func (s *Server) PrintLogo()

func (*Server) Register

func (s *Server) Register(srvDesc *ServiceDesc, srv interface{}, opts ...Option)

func (*Server) RegisterService

func (s *Server) RegisterService(serviceName string, service interface{}, options ...Option) error

func (*Server) Serve

func (s *Server) Serve() error

type Service

type Service interface {
	Register(string, FilterFunc)
	Serve(o *Options) error
	Close()
	// contains filtered or unexported methods
}

type ServiceDesc

type ServiceDesc struct {
	Svr         interface{}
	ServiceName string
	HandlerType interface{}
	Methods     []*Method
}

Jump to

Keyboard shortcuts

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