Documentation ¶
Index ¶
Constants ¶
View Source
const ShutdownTimeout = time.Second * 10
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AsyncValue ¶
type AsyncValue[T any] struct { Cond *sync.Cond Value *T Err error // contains filtered or unexported fields }
func NewAsyncValue ¶
func NewAsyncValue[T any]() *AsyncValue[T]
NewAsyncValue creates a new AsyncValue object with a condition variable and a mutex.
func (*AsyncValue[T]) Get ¶
func (a *AsyncValue[T]) Get(ctx context.Context) (*T, error)
Get is a function that attempts to retrieve a value from a given context, and returns the value or an error if the context is done or an error occurs.
func (*AsyncValue[T]) Put ¶
func (a *AsyncValue[T]) Put(value *T)
Put takes in a pointer to a value and sets it as the value of the AsyncValue, then broadcasts the change to any waiting goroutines.
func (*AsyncValue[T]) PutErr ¶
func (a *AsyncValue[T]) PutErr(err error)
PutErr sets an error value on the AsyncValue struct and broadcasts the condition variable to notify any waiting goroutines.
type Host ¶
type Host struct { // Slice of services to run. Started in order. Services []Service // LoggerValues is key-value-pairs passed to .WithValues to initialize the logger for the host. LoggerValues []any // TimeoutFunc allows you to control the timeout behavior for testing TimeoutFunc func() }
Host manages the lifetimes and starting of Services.
type LifecycleMessage ¶
LifecycleMessage is a message returned when a service terminates.
Click to show internal directories.
Click to hide internal directories.