server

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package server is a package for protocol of a micro service

Index

Constants

This section is empty.

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() 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
	ChainName string
	Provider  provider.Provider
	TLSConfig *tls.Config
}

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 WithSchemaID

func WithSchemaID(schemaID string) RegisterOption

WithSchemaID you can specify a unique id for schema

type RegisterOptions

type RegisterOptions struct {
	SchemaID string
}

RegisterOptions is options when you register a schema to chassis

Jump to

Keyboard shortcuts

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