service

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MulanPSL-2.0 Imports: 7 Imported by: 1

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 Bind

func Bind(fn func(*grpc.Server)) 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 Logger

func Logger(log *glog.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 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 Tracing

func Tracing(t bool) Option

func Version

func Version(v string) Option

Version of the service

type Options

type Options struct {
	Server         server.Server
	RegistryEnable bool
	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

	//Bind rpc register
	Bind func(*grpc.Server)

	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
	Logger  *glog.Logger
	Tracing bool
}

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