service

package
v1.0.1-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthOptions

type AuthOptions []auth.Option

func (AuthOptions) Options

func (a AuthOptions) Options() auth.Options

type BrokerOptions

type BrokerOptions []broker.Option

func (BrokerOptions) Options

func (b BrokerOptions) Options() broker.Options

type ClientOptions

type ClientOptions []client.Option

func (ClientOptions) Options

func (c ClientOptions) Options() client.Options

type ConfigOptions

type ConfigOptions []config.Option

func (ConfigOptions) Options

func (c ConfigOptions) Options() config.Options

type Function

type Function interface {
	// Inherits Service interface
	Service
	// Done signals to complete execution
	Done() error
	// Handle registers an RPC handler
	Handle(v interface{}) error
	// Subscribe registers a subscriber
	Subscribe(topic string, v interface{}) error
}

Function is a one time executing Service

type LoggerOptions

type LoggerOptions []logger.Option

func (LoggerOptions) Options

func (c LoggerOptions) Options() logger.Options

type Option

type Option func(o *Options)

func Address

func Address(addr string) Option

Address sets the address of the server

func AfterStart

func AfterStart(fn func() error) Option

func AfterStop

func AfterStop(fn func() error) Option

func Auth

func Auth(au auth.Auth) Option

func BeforeInit

func BeforeInit(fn func(sOpts *Options) error) Option

func BeforeStart

func BeforeStart(fn func() error) Option

func BeforeStop

func BeforeStop(fn func() error) Option

func Broker

func Broker(b broker.Broker) Option

func Client

func Client(c client.Client) Option

func Cmd

func Cmd(c cmd.Cmd) Option

func Config

func Config(c config.Config) Option

func Context

func Context(ctx context.Context) Option

Context specifies a context for the service. Can be used to signal shutdown of the service. Can be used for extra option values.

func HandleSignal

func HandleSignal(b bool) Option

HandleSignal toggles automatic installation of the signal handler that traps TERM, INT, and QUIT. Users of this feature to disable the signal handler, should control liveness of the service through the context.

func Id

func Id(id string) Option

Unique server id

func Logger

func Logger(l logger.Logger) Option

func Metadata

func Metadata(md map[string]string) Option

Metadata associated with the service

func Name

func Name(n string) Option

Name of the service

func Profile

func Profile(p profile.Profile) Option

Profile to be used for debug profile

func RPC

func RPC(r string) Option

RPC sets the type of service, eg. stack, grpc but this func will be deprecated

func RegisterInterval

func RegisterInterval(t time.Duration) Option

RegisterInterval specifies the interval on which to re-register

func RegisterTTL

func RegisterTTL(t time.Duration) Option

RegisterTTL specifies the TTL to use when registering the service

func Registry

func Registry(r registry.Registry) Option

Registry sets the registry for the service and the underlying components

func Selector

func Selector(s selector.Selector) Option

Selector sets the selector for the service client

func Server

func Server(s server.Server) Option

func Transport

func Transport(t transport.Transport) Option

Transport sets the transport for the service and the underlying components

func Version

func Version(v string) Option

Version of the service

func WrapCall

func WrapCall(w ...client.CallWrapper) Option

WrapCall is a convenience method for wrapping a Client CallFunc

func WrapClient

func WrapClient(w ...client.Wrapper) Option

WrapClient is a convenience method for wrapping a Client with some middleware component. A list of wrappers can be provided. Wrappers are applied in reverse order so the last is executed first.

func WrapHandler

func WrapHandler(w ...server.HandlerWrapper) Option

WrapHandler adds a handler Wrapper to a list of options passed into the server

func WrapSubscriber

func WrapSubscriber(w ...server.SubscriberWrapper) Option

WrapSubscriber adds a subscriber Wrapper to a list of options passed into the server

type Options

type Options struct {
	// maybe put them in metadata is better
	Id   string
	Name string
	RPC  string
	Cmd  cmd.Cmd
	Conf string

	BrokerOptions    BrokerOptions
	ClientOptions    ClientOptions
	ServerOptions    ServerOptions
	RegistryOptions  RegistryOptions
	TransportOptions TransportOptions
	SelectorOptions  SelectorOptions
	ConfigOptions    ConfigOptions
	LoggerOptions    LoggerOptions
	AuthOptions      AuthOptions

	Broker    broker.Broker
	Client    client.Client
	Server    server.Server
	Registry  registry.Registry
	Transport transport.Transport
	Selector  selector.Selector
	Config    config.Config
	Logger    logger.Logger
	Auth      auth.Auth
	Profile   profile.Profile

	// Before and After funcs
	BeforeInit  []func(sOpts *Options) error
	BeforeStart []func() error
	BeforeStop  []func() error
	AfterStart  []func() error
	AfterStop   []func() error

	ClientWrapper     []client.Wrapper
	CallWrapper       []client.CallWrapper
	HandlerWrapper    []server.HandlerWrapper
	SubscriberWrapper []server.SubscriberWrapper
	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context

	Signal bool
}

type RegistryOptions

type RegistryOptions []registry.Option

func (RegistryOptions) Options

func (c RegistryOptions) Options() registry.Options

type SelectorOptions

type SelectorOptions []selector.Option

func (SelectorOptions) Options

func (c SelectorOptions) Options() selector.Options

type ServerOptions

type ServerOptions []server.Option

func (ServerOptions) Options

func (c ServerOptions) Options() server.Options

type Service

type Service interface {
	// The service name
	Name() string
	// Init initialises options
	Init(...Option) error
	// Options returns the current options
	Options() Options
	// Client is used to call services
	Client() client.Client
	// Server is for handling requests and events
	Server() server.Server
	//  Run the service
	Run() error
	// The service implementation
	String() string
}

Service is an interface that wraps the lower level libraries within stack. Its a convenience method for building and initialising services.

type TransportOptions

type TransportOptions []transport.Option

func (TransportOptions) Options

func (c TransportOptions) Options() transport.Options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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