service

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2020 License: Apache-2.0 Imports: 6 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)

Option Option

func AfterStart

func AfterStart(fn func() error) Option

AfterStart Before and Afters

func AfterStop

func AfterStop(fn func() error) Option

AfterStop Before and Afters

func BeforeStart

func BeforeStart(fn func() error) Option

BeforeStart Before and Afters

func BeforeStop

func BeforeStop(fn func() error) Option

BeforeStop Before and Afters

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

Server Server

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
}

Options Options

type Service

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

Service Service

func NewService

func NewService(opts ...Option) Service

NewService NewService

Jump to

Keyboard shortcuts

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