ctx

package
v0.9.25 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: Apache-2.0 Imports: 15 Imported by: 12

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 GetService added in v0.8.1

func GetService(serviceName string) any

func GetTypedService added in v0.9.16

func GetTypedService[T any]() T

func InjectEnv added in v0.9.25

func InjectEnv(target any)

func Run added in v0.8.1

func Run(fn func())

func RunFinally added in v0.8.1

func RunFinally(fn func(), finallyFn func())

func RunWithRecover added in v0.9.3

func RunWithRecover(fn func())

func ServiceArray

func ServiceArray(srvs ...any) []any

func StartContextualizedApplication deprecated

func StartContextualizedApplication(servicePackages ...[]any)

Deprecated: use ctx.CreateContextualizedApplication with .Join() call

Types

type AppContext

type AppContext interface {
	GetService(serviceName string) any
	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 CreateContextualizedApplication added in v0.9.16

func CreateContextualizedApplication(servicePackages ...ServicePackage) Application

func StartApplication deprecated added in v0.9.15

func StartApplication(servicePackages ...[]any) Application

Deprecated: use CreateContextualizedApplication instead

type ConnectableService

type ConnectableService[In any, Out any] interface {
	Service
	OnMessage(In)
	Send(Out)
}

type Constructable added in v0.9.18

type Constructable interface {
	Init()
}

type Disposable added in v0.8.0

type Disposable interface {
	Dispose()
}

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 LifecycleAware deprecated

type LifecycleAware interface {
	StartAware
	StopAware
}

Deprecated: use ctx.StartAware and ctx.StopAware

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 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 Service

type Service interface {
	Initializable
	Named
	Disposable
}

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
	IsLifecycleAware bool //Deprecated
	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