ctx

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: Apache-2.0 Imports: 23 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectServices

func ConnectServices(services ...string) any

func DefineServiceName added in v0.9.16

func DefineServiceName(service any) string

func Env added in v0.10.6

func Env[T any]() T

func GetService added in v0.8.1

func GetService(serviceName string) (svc any, ok bool)

func GetTypedService added in v0.9.16

func GetTypedService[T any]() (svc T, ok bool)

func InitSlog added in v0.10.1

func InitSlog()

func InjectEnv added in v0.9.25

func InjectEnv(target any)

func NewSlogLegacyHandler added in v0.10.5

func NewSlogLegacyHandler(w io.Writer, level slog.Level, addSource bool) slog.Handler

func SetSlogHandler added in v0.10.1

func SetSlogHandler(handler slog.Handler)

func SetSlogWriter added in v0.10.5

func SetSlogWriter(writers ...io.Writer)

Types

type AppContext

type AppContext interface {
	GetService(serviceName string) (any, bool)
	Stats() AppContextStats
	Health() AppContextHealth
	State() (int, string)
}

type AppContextHealth added in v0.9.7

type AppContextHealth interface {
	Aggregate() health.ServiceHealth
}

type AppContextStats added in v0.9.7

type AppContextStats interface {
	Services() map[string]ServiceDescriptor
}

type Application added in v0.9.15

type Application interface {
	Stop() Application
	Join()
}

func CreateAutoContextualizedApplication added in v0.11.2

func CreateAutoContextualizedApplication() Application

func CreateContextualizedApplication added in v0.9.16

func CreateContextualizedApplication(servicePackages ...ServicePackage) Application

type ConnectableService

type ConnectableService[In any, Out any] interface {
	Initializable
	Disposable
	Named
	OnMessage(In)
	Send(Out)
}

type Constructable added in v0.9.18

type Constructable interface {
	Init()
}

type ConstructableContext added in v0.10.7

type ConstructableContext interface {
	Init(context context.Context)
}

type ConstructableContextE added in v0.11.0

type ConstructableContextE interface {
	Init(context context.Context) error
}

type ConstructableE added in v0.11.0

type ConstructableE interface {
	Init() error
}

type Disposable added in v0.8.0

type Disposable interface {
	Dispose()
}

type DisposableE added in v0.11.0

type DisposableE interface {
	Dispose() error
}

type EnvValue

type EnvValue struct {
	// contains filtered or unexported fields
}

func GetEnv

func GetEnv(name string) *EnvValue

func GetEnvCustom added in v0.9.0

func GetEnvCustom(custom string, name string) *EnvValue

func GetEnvCustomOrDefault added in v0.9.0

func GetEnvCustomOrDefault(custom string, name string) *EnvValue

func (*EnvValue) AsBool

func (instance *EnvValue) AsBool() bool

func (*EnvValue) AsBoolDefault

func (instance *EnvValue) AsBoolDefault(def bool) bool

func (*EnvValue) AsDuration added in v0.9.3

func (instance *EnvValue) AsDuration() time.Duration

func (*EnvValue) AsDurationDefault added in v0.9.3

func (instance *EnvValue) AsDurationDefault(def time.Duration) time.Duration

func (*EnvValue) AsInt

func (instance *EnvValue) AsInt() int

func (*EnvValue) AsInt64 added in v0.9.0

func (instance *EnvValue) AsInt64() int64

func (*EnvValue) AsInt64Array added in v0.9.0

func (instance *EnvValue) AsInt64Array() []int64

func (*EnvValue) AsInt64ArrayDefault added in v0.9.0

func (instance *EnvValue) AsInt64ArrayDefault() []int64

func (*EnvValue) AsInt64Default added in v0.9.0

func (instance *EnvValue) AsInt64Default(def int64) int64

func (*EnvValue) AsInt64Set added in v0.9.11

func (instance *EnvValue) AsInt64Set() map[int64]bool

func (*EnvValue) AsInt64SetDefault added in v0.9.11

func (instance *EnvValue) AsInt64SetDefault() map[int64]bool

func (*EnvValue) AsIntArray

func (instance *EnvValue) AsIntArray() []int

func (*EnvValue) AsIntArrayDefault

func (instance *EnvValue) AsIntArrayDefault() []int

func (*EnvValue) AsIntDefault

func (instance *EnvValue) AsIntDefault(def int) int

func (*EnvValue) AsIntSet added in v0.9.11

func (instance *EnvValue) AsIntSet() map[int]bool

func (*EnvValue) AsIntSetDefault added in v0.9.11

func (instance *EnvValue) AsIntSetDefault() map[int]bool

func (*EnvValue) AsMap

func (instance *EnvValue) AsMap() map[string]*EnvValue

func (*EnvValue) AsMapDefault added in v0.9.13

func (instance *EnvValue) AsMapDefault() map[string]*EnvValue

func (*EnvValue) AsString

func (instance *EnvValue) AsString() string

func (*EnvValue) AsStringArray

func (instance *EnvValue) AsStringArray() []string

func (*EnvValue) AsStringArrayDefault

func (instance *EnvValue) AsStringArrayDefault(def []string) []string

func (*EnvValue) AsStringDefault

func (instance *EnvValue) AsStringDefault(def string) string

func (*EnvValue) AsStringSet added in v0.9.11

func (instance *EnvValue) AsStringSet() map[string]bool

func (*EnvValue) AsStringSetDefault added in v0.9.11

func (instance *EnvValue) AsStringSetDefault(def []string) map[string]bool

func (*EnvValue) IsPresent

func (instance *EnvValue) IsPresent() bool

func (*EnvValue) Name added in v0.8.0

func (instance *EnvValue) Name() string

func (*EnvValue) String added in v0.9.0

func (instance *EnvValue) String() string

type HealthReporter added in v0.9.7

type HealthReporter interface {
	Health() health.ServiceHealth
}

type Initializable added in v0.8.0

type Initializable interface {
	Init(serviceProvider ServiceProvider)
}

type InitializableContext added in v0.10.7

type InitializableContext interface {
	Init(context context.Context, serviceProvider ServiceProvider)
}

type InitializableContextE added in v0.11.0

type InitializableContextE interface {
	Init(context context.Context, serviceProvider ServiceProvider) error
}

type InitializableE added in v0.11.0

type InitializableE interface {
	Init(serviceProvider ServiceProvider) error
}

type Named added in v0.8.0

type Named interface {
	Name() string
}

type NamedService added in v0.9.16

type NamedService struct {
	// contains filtered or unexported fields
}

func Typed added in v0.11.2

func Typed[T any]() NamedService

func TypedWithName added in v0.11.2

func TypedWithName[T any](name string) NamedService

func WithName added in v0.9.16

func WithName(name string, service any) NamedService

func (*NamedService) Name added in v0.9.16

func (n *NamedService) Name() string

func (*NamedService) Service added in v0.9.16

func (n *NamedService) Service() any

type ServiceConnector

type ServiceConnector[In any, Out any] struct {
	// contains filtered or unexported fields
}

func NewServiceConnector

func NewServiceConnector[In any, Out any](service ConnectableService[In, Out]) ServiceConnector[In, Out]

func (*ServiceConnector[In, Out]) AfterStart

func (connector *ServiceConnector[In, Out]) AfterStart()

func (*ServiceConnector[In, Out]) BeforeStop

func (connector *ServiceConnector[In, Out]) BeforeStop()

func (*ServiceConnector[In, Out]) Send

func (connector *ServiceConnector[In, Out]) Send(msg Out)

type ServiceDescriptor added in v0.9.4

type ServiceDescriptor struct {
	Name         string
	Type         reflect.Type
	IsStartAware bool
	IsStopAware  bool
	Dependencies []string
}

type ServicePackage added in v0.9.16

type ServicePackage struct {
	// contains filtered or unexported fields
}

func PackageOf added in v0.9.16

func PackageOf(services ...any) ServicePackage

func (*ServicePackage) ForEach added in v0.9.16

func (p *ServicePackage) ForEach(fn func(service any, name string))

type ServiceProvider added in v0.8.0

type ServiceProvider interface {
	ByName(name string) any
	ByType(sType any) any
	// contains filtered or unexported methods
}

type StartAware added in v0.9.21

type StartAware interface {
	AfterStart()
}

type StopAware added in v0.9.21

type StopAware interface {
	BeforeStop()
}

type TimerTask

type TimerTask struct {
	// contains filtered or unexported fields
}

func (*TimerTask) StartTimer

func (instance *TimerTask) StartTimer(interval time.Duration, actionOnTimer func())

func (*TimerTask) StopTimer

func (instance *TimerTask) StopTimer()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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