service

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2019 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options)

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 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 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

func Version

func Version(v string) Option

Version of the service

type Options

type Options struct {
	Server   server.Server
	Registry registry.Registry

	// Register loop interval
	RegisterInterval time.Duration

	// 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
}

type Service

type Service interface {
	Init(...Option)
	Options() Options
	Server() server.Server
	Run() error
	String() string
}

func NewService

func NewService(opts ...Option) Service

Jump to

Keyboard shortcuts

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