service

package
v3.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package service encapsulates the client, server and other interfaces to provide a complete micro service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*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 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 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 Metadata

func Metadata(md map[string]string) Option

Metadata associated with the service

func Model

func Model(m model.Model) Option

Model sets the model for data access

func Name

func Name(n string) Option

Name of the service

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 Server

func Server(s server.Server) Option

Server sets the server for handling requests

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 {
	Broker   broker.Broker
	Client   client.Client
	Server   server.Server
	Model    model.Model
	Registry registry.Registry

	// Before and After funcs
	BeforeStart []func() error
	BeforeStop  []func() error
	AfterStart  []func() error
	AfterStop   []func() error

	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

func NewOptions

func NewOptions(opts ...Option) Options

type Service

type Service interface {
	// The service name
	Name() string
	// Init initialises options
	Init(...Option)
	// 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
	// Model is used to access data
	Model() model.Model
	// Run the service
	Run() error
	// The service implementation
	String() string
}

Service is an interface for a micro service

Directories

Path Synopsis
Package mucp initialises a mucp service
Package mucp initialises a mucp service

Jump to

Keyboard shortcuts

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