server

package
Version: v0.0.0-...-5dc8409 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2018 License: Apache-2.0, Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package server is an interface for a micro server

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	ChainName: "default",
	Metadata:  map[string]string{},
}

Functions

This section is empty.

Types

type Option

type Option func(*Options)

func Address

func Address(a string) Option

Address to bind to - host:port

func Advertise(a string) Option

The address to advertise for discovery - host:port

func ChainName

func ChainName(n string) Option

func ID

func ID(id string) Option

Unique server id

func Metadata

func Metadata(md map[string]string) Option

Metadata associated with the server

func Name

func Name(n string) Option

Server name

func Provider

func Provider(p provider.Provider) Option

func RegisterTTL

func RegisterTTL(t time.Duration) Option

Register the service with a TTL

func TLSConfig

func TLSConfig(t *tls.Config) Option

func Transport

func Transport(t transport.Transport) Option

Transport mechanism for communication e.g http, rabbitmq, etc

func Version

func Version(v string) Option

Version of the service

func WithCodecs

func WithCodecs(c map[string]codec.Codec) Option

WithCodecs set Codecs

type Options

type Options struct {
	Codecs    map[string]codec.Codec
	Transport transport.Transport
	Metadata  map[string]string
	//protocol
	Name      string
	Address   string
	Advertise string
	ID        string
	Version   string
	//singleton
	ChainName string
	//each microservice is a provider
	Provider    provider.Provider
	RegisterTTL time.Duration
	// Other options for implementations of the interface
	// can be stored in a context
	Context   context.Context
	TLSConfig *tls.Config
}

type RegisterOption

type RegisterOption func(*RegisterOptions)

func WithGrpcRegister

func WithGrpcRegister(grpcRegister interface{}) RegisterOption

WithGrpcRegister set GrpcRegister

func WithMicroServiceName

func WithMicroServiceName(microservice string) RegisterOption

func WithSchemaID

func WithSchemaID(schemaID string) RegisterOption

func WithServiceProvider

func WithServiceProvider(provider provider.Provider) RegisterOption

type RegisterOptions

type RegisterOptions struct {
	MicroServiceName string
	SchemaID         string
	Provider         provider.Provider
	//only grpc protocol use the param
	GrpcRegister interface{}
}

type Server

type Server interface {
	Options() Options
	Init(...Option) error
	//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
}

Server interface for the server it implements innit, register, start, and stop the server..

Jump to

Keyboard shortcuts

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