Documentation
¶
Overview ¶
Package service defines the interfaces of a microservice, which the connector implements.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigChangedHandler ¶
StartupHandler handles the OnStartup callback.
type Configurable ¶
type Configurable interface {
DefineConfig(name string, options ...cfg.Option) error
Config(name string) (value string)
SetConfig(name string, value any) error
ResetConfig(name string) error
SetOnConfigChanged(handler ConfigChangedHandler) error
}
Configurable are the actions used to configure the microservice.
type Executor ¶
type Executor interface {
Go(ctx context.Context, f func(ctx context.Context) (err error)) error
Parallel(jobs ...func() (err error)) error
}
Executor are actions for running jobs in Go routines.
type Identifier ¶
type Identifier interface {
ID() string
Hostname() string
Description() string
Version() int
Deployment() string
Plane() string
Locality() string
}
Identifier are the properties used to uniquely identify and address the microservice.
type Logger ¶
type Logger interface {
LogDebug(ctx context.Context, msg string, fields ...log.Field)
LogInfo(ctx context.Context, msg string, fields ...log.Field)
LogWarn(ctx context.Context, msg string, fields ...log.Field)
LogError(ctx context.Context, msg string, fields ...log.Field)
}
Subscriber are the actions used to output log messages.
type Publisher ¶
type Publisher interface {
Request(ctx context.Context, options ...pub.Option) (*http.Response, error)
Publish(ctx context.Context, options ...pub.Option) <-chan *pub.Response
}
Publisher are the actions used to publish to the bus.
type PublisherSubscriber ¶
type PublisherSubscriber interface {
Publisher
Subscriber
}
PublisherSubscriber is both a publisher and a subscriber.
type Service ¶
type Service interface {
Publisher
Subscriber
Logger
Tracer
StarterStopper
Identifier
Configurable
Resourcer
Ticker
Executor
}
Service are all the actions that a connector provides.
type ShutdownHandler ¶
StartupHandler handles the OnShutdown callback.
type StarterStopper ¶
type StarterStopper interface {
Startup() (err error)
Shutdown() error
IsStarted() bool
Lifetime() context.Context
SetHostname(hostname string) error
SetDeployment(deployment string) error
SetPlane(plane string) error
SetOnStartup(handler StartupHandler) error
SetOnShutdown(handler ShutdownHandler) error
}
StarterStopper are the lifecycle actions of the microservice.
type StartupHandler ¶
StartupHandler handles the OnStartup callback.
type Subscriber ¶
type Subscriber interface {
Subscribe(method string, path string, handler sub.HTTPHandler, options ...sub.Option) error
Unsubscribe(method string, path string) error
}
Subscriber are the actions used to subscribe to the bus.
type Ticker ¶
type Ticker interface {
StartTicker(name string, interval time.Duration, handler TickerHandler) error
}
Ticker are actions used to schedule recurring jobs.
type TickerHandler ¶
TickerHandler handles the ticker callbacks.