Documentation
¶
Overview ¶
Package service defines the interfaces of a microservice, which the connector implements.
Index ¶
- type ConfigChangedHandler
- type Configurable
- type Executor
- type Identifier
- type Logger
- type Meter
- type MeterDescriber
- type ObserveMetricsHandler
- type Publisher
- type PublisherSubscriber
- type Resourcer
- type Service
- type ShutdownHandler
- type StarterStopper
- type StartupHandler
- type Subscriber
- type Ticker
- type TickerHandler
- type Timer
- type Tracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigChangedHandler ¶
ConfigChangedHandler handles the OnConfigChanged 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, args ...any)
LogInfo(ctx context.Context, msg string, args ...any)
LogWarn(ctx context.Context, msg string, args ...any)
LogError(ctx context.Context, msg string, args ...any)
}
Logger are the actions used to output log messages.
type Meter ¶ added in v1.13.1
type Meter interface {
IncrementCounter(ctx context.Context, name string, val float64, attributes ...any) (err error)
RecordGauge(ctx context.Context, name string, val float64, attributes ...any) (err error)
RecordHistogram(ctx context.Context, name string, val float64, attributes ...any) (err error)
}
Meter are the actions used to record metrics.
type MeterDescriber ¶ added in v1.13.1
type MeterDescriber interface {
DescribeCounter(name string, desc string) (err error)
DescribeGauge(name string, desc string) (err error)
DescribeHistogram(name string, desc string, buckets []float64) (err error)
SetOnObserveMetrics(handler ObserveMetricsHandler) error
}
MeterDescriber are the actions used to describe metrics.
type ObserveMetricsHandler ¶ added in v1.13.1
ObserveMetricsHandler handles the OnObserveMetrics callback.
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
MeterDescriber
Meter
Tracer
StarterStopper
Identifier
Configurable
Resourcer
Ticker
Timer
Executor
}
Service are all the actions that a connector provides.
type ShutdownHandler ¶
ShutdownHandler handles the OnShutdown callback.
type StarterStopper ¶
type StarterStopper interface {
Startup(ctx context.Context) (err error)
Shutdown(ctx context.Context) 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) (unsub func() (err error), err 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.