managed

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QualifierLifecycle   = "lifecycle"
	QualifierRetry       = "retry"
	QualifierHttpHandler = "http_handler"
	QualifierHealth      = "health"
)
View Source
const (
	QualifierConfiguration = "configuration"
	QualifierService       = "service"
	QualifierComponent     = "component"
)
View Source
const (
	ConfHttpPort                    = "ConfHttpPort"
	ConfHttpReadTimeoutMillisecond  = "ConfReadTimeoutMillisecond"
	ConfHttpWriteTimeoutMillisecond = "ConfWriteTimeoutMillisecond"
	ConfHttpTlsKeyPath              = "ConfHttpTlsKeyPath"
	ConfHttpTlsCertPath             = "ConfHttpTlsCertPath"
)
View Source
const (
	ConfRetryAttempts             = "ConfRetryAttempts"
	ConfRetryDelayMillisecond     = "ConfRetryDelayMillisecond"
	ConfRetryMaxDelayMillisecond  = "ConfRetryMaxDelayMillisecond"
	ConfRetryMaxJitterMillisecond = "ConfRetryMaxJitterMillisecond"
	ConfRetryAbsorbError          = "ConfRetryAbsorbError"
)
View Source
const (
	QualifierConfigPrefix = "config"
)

Variables

View Source
var (
	ErrHttpMissingServer         = errors.New("http runtime no server provided")
	ErrHttpMissingHandler        = errors.New("http runtime no handler provided")
	ErrHttpFailedToInitialiseTls = errors.New("http runtime failed to start tls")
)

Errors

View Source
var (
	ErrLoopRuntimeNoLoop     = errors.New("functional runtime no loop function provided")
	ErrLoopRuntimeInitialise = errors.New("functional runtime initialise function failed")
)

Errors

View Source
var (
	ErrRunnerRuntimeNoRunnable    = errors.New("runner runtime no runnable provided")
	ErrRunnerRuntimeRunnableStart = errors.New("runner runtime runnable failed to start")
)

Errors

View Source
var (
	ErrChannelRuntimeNoChannel = errors.New("functional runtime no Channel function provided")
)

Errors

View Source
var ErrConfigMissingTarget = errors.New("configuration target missing")
View Source
var (
	ErrLifecycleStartError = errors.New("lifecycle start failed")
)
View Source
var ErrRetryStopped = errors.New("retry stopped")

Functions

func AddComponent added in v0.2.11

func AddComponent(ic inverse.Container, comp Component)

func AddConfiguration added in v0.2.11

func AddConfiguration(ic inverse.Container, component string, configuration map[string]string)

func AddHealth added in v0.2.15

func AddHealth(ic inverse.Container)

func AddHttp added in v0.2.15

func AddHttp(ic inverse.Container)

func AddHttpConfig added in v0.2.15

func AddHttpConfig(ic inverse.Container, conf map[string]string)

func AddHttpHandler added in v0.2.15

func AddHttpHandler(ic inverse.Container, ij inverse.Injector[http.Handler])

func AddQualifiedRetry added in v0.2.15

func AddQualifiedRetry(ic inverse.Container, qualifier string)

func AddRetry added in v0.2.15

func AddRetry(ic inverse.Container)

func AddService added in v0.2.11

func AddService(ic inverse.Container, svc Service)

func AlwaysTry

func AlwaysTry(err error) bool

func New

func New(
	ic inverse.Container,
	ctx context.Context,
) (
	runtime.Runtime,
	error,
)

Types

type Channel

type Channel[T any] interface {
	Channel() (<-chan T, error)
	Loop(T) error
}

type Component

type Component interface {
	Name() string
	Register(context.Context, inverse.Container) error
	Resolve(context.Context, inverse.Container) error
	Clean() error
}

lifecycle: register -> resolve -> clean

type Configuration

type Configuration interface {
	Component

	Has(key string) bool
	Get() map[string]string
	GetString(key string, defaultValue string) string
	GetBool(key string, defaultValue bool) bool
	GetInt32(key string, defaultValue int32) int32
	GetInt64(key string, defaultValue int64) int64
	GetUint32(key string, defaultValue uint32) uint32
	GetUint64(key string, defaultValue uint64) uint64
}

func EmptyConfig

func EmptyConfig(component string) Configuration

func GetConfig added in v0.2.15

func GetConfig(container inverse.Container, ctx context.Context, component string) (Configuration, error)

func NewConfig

func NewConfig(component string, configuration map[string]string) Configuration

type Health

type Health interface {
	Component

	GetString() map[string]string
	SetString(component string, key string, value string)
	GetBool() map[string]bool
	SetBool(component string, key string, value bool)
	GetInt() map[string]int64
	SetInt(component string, key string, value int64)
	IncInt(component string, key string, value int64)
	DecInt(component string, key string, value int64)
}

func GetHealth added in v0.2.15

func GetHealth(container inverse.Container, ctx context.Context) (Health, error)

type Lifecycle

type Lifecycle interface {
	Service

	Running() bool
	Error(error)
}

func GetLifecycle added in v0.2.15

func GetLifecycle(container inverse.Container, ctx context.Context) (Lifecycle, error)

type Loop

type Loop interface {
	Loop() error
}

type Retry

type Retry interface {
	Component

	Do(fnToDo func(int64) error) error
}

func GetQualifiedRetry added in v0.2.15

func GetQualifiedRetry(container inverse.Container, ctx context.Context, qualifier string) (Retry, error)

func GetRetry added in v0.2.15

func GetRetry(container inverse.Container, ctx context.Context) (Retry, error)

type Runnable

type Runnable interface {
	Run() error
}

type Service

type Service interface {
	Component

	Start() error
	Stop() error
}

lifecycle: register -> resolve -> start -> stop -> clean

func NewChannel

func NewChannel[T any](channel Channel[T]) Service

func NewLoop

func NewLoop(loop Loop) []Service

func NewRunner

func NewRunner(runnable Runnable) Service

Jump to

Keyboard shortcuts

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