managed

package
v0.2.6 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: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QualifierLifecycle   = "lifecycle"
	QualifierRetry       = "retry"
	QualifierHttpHandler = "http-handler"
	QualifierHealth      = "health"
)
View Source
const (
	ConfHttpPort                    = "ConfHttpPort"
	ConfHttpReadTimeoutMillisecond  = "ConfReadTimeoutMillisecond"
	ConfHttpWriteTimeoutMillisecond = "ConfWriteTimeoutMillisecond"
	ConfHttpTlsKeyPath              = "ConfHttpTlsKeyPath"
	ConfHttpTlsCertPath             = "ConfHttpTlsCertPath"
)
View Source
const (
	ConfManagerName             = "ConfManagerName"
	ConfManagerRuntimeQualifier = "ConfManagerRuntimeQualifier"
	ConfManagerQualifier        = "ConfManagerQualifier"

	DefaultManagerRuntimeQualifier = "ManagedRuntime"
)
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 AlwaysTry

func AlwaysTry(err error) bool

func New

func New(
	ctx context.Context,
	ic inverse.Container,
	services []Service,
	components []Component,
	configurations []Configuration,
) runtime.Runtime

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 NewConfig

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

func ResolveConfig

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

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 NewHealth

func NewHealth() Health

func ResolveHealth

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

type Lifecycle

type Lifecycle interface {
	Service

	Running() bool
	Error(error)
}

func ResolveLifecycle

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

type Loop

type Loop interface {
	Loop() error
}

type Retry

type Retry interface {
	Component

	Do(fnToDo func(int64) error) error
}

func NewQualifiedRetry

func NewQualifiedRetry(qualifier string) Retry

func NewRetry

func NewRetry() Retry

func ResolveRetry

func ResolveRetry(ctx context.Context, container inverse.Container, qualifier string) (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 NewHttp

func NewHttp() []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