service

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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

type ConfigChangedHandler func(ctx context.Context, changed func(string) bool) error

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

type ObserveMetricsHandler func(ctx context.Context) error

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 Resourcer

type Resourcer interface {
	SetResFS(resFS fs.FS) error
	ResFS() fs.FS
}

Resourcer provides access to the connector's FS.

type Service

Service are all the actions that a connector provides.

type ShutdownHandler

type ShutdownHandler func(ctx context.Context) error

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

type StartupHandler func(ctx context.Context) error

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

type TickerHandler func(ctx context.Context) error

TickerHandler handles the ticker callbacks.

type Timer added in v1.19.0

type Timer interface {
	Now(ctx context.Context) time.Time
	Sleep(ctx context.Context, duration time.Duration) bool
}

Timer are actions related to time management.

type Tracer

type Tracer interface {
	StartSpan(ctx context.Context, spanName string, opts ...trc.Option) (context.Context, trc.Span)
	Span(ctx context.Context) trc.Span
	ForceTrace(ctx context.Context)
}

Tracer are the actions used to operate distributed tracing spans.

Jump to

Keyboard shortcuts

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