Documentation ¶
Index ¶
- Constants
- Variables
- func Call[Req, Resp any](ctx context.Context, verb Verb[Req, Resp], req Req) (Resp, error)
- func CallEmpty(ctx context.Context, empty Empty) error
- func CallSink[Req any](ctx context.Context, sink Sink[Req], req Req) error
- func CallSource[Resp any](ctx context.Context, source Source[Resp]) (Resp, error)
- func Module() string
- type ConfigType
- type ConfigValue
- type Database
- type Empty
- type FSMHandle
- type FSMTransition
- type Handle
- type LeaseHandle
- type Logger
- type MapHandle
- type Option
- func (o Option[T]) Default(value T) T
- func (o Option[T]) Get() (T, bool)
- func (o Option[T]) GoString() string
- func (o Option[T]) MarshalJSON() ([]byte, error)
- func (o Option[T]) MustGet() T
- func (o Option[T]) Ok() bool
- func (o Option[T]) Ptr() *T
- func (o *Option[T]) Scan(src any) error
- func (o Option[T]) String() string
- func (o *Option[T]) UnmarshalJSON(data []byte) error
- func (o Option[T]) Value() (driver.Value, error)
- type Ref
- type SecretType
- type SecretValue
- type Sink
- type Source
- type Unit
- type Verb
Constants ¶
const ( Trace = log.Trace Debug = log.Debug Info = log.Info Warn = log.Warn Error = log.Error Default = log.Default )
Log levels.
Variables ¶
var ErrLeaseHeld = fmt.Errorf("lease already held")
ErrLeaseHeld is returned when an attempt is made to acquire a lease that is already held.
Functions ¶
func CallEmpty ¶ added in v0.149.2
CallEmpty calls a Verb with no request or response through the FTL controller.
func CallSource ¶ added in v0.149.2
CallSource calls a Source through the FTL controller.
Types ¶
type ConfigType ¶
type ConfigType interface{ any }
ConfigType is a type that can be used as a configuration value.
type ConfigValue ¶
type ConfigValue[T ConfigType] struct { Ref }
ConfigValue is a typed configuration key for the current module.
func Config ¶
func Config[T ConfigType](name string) ConfigValue[T]
Config declares a typed configuration key for the current module.
func (ConfigValue[T]) Get ¶
func (c ConfigValue[T]) Get(ctx context.Context) (out T)
Get returns the value of the configuration key from FTL.
func (ConfigValue[T]) GoString ¶ added in v0.138.2
func (c ConfigValue[T]) GoString() string
func (ConfigValue[T]) String ¶
func (c ConfigValue[T]) String() string
type Database ¶ added in v0.183.0
type Database struct { Name string DBType modulecontext.DBType }
func PostgresDatabase ¶
PostgresDatabase returns a handler for the named database.
type FSMHandle ¶ added in v0.202.0
type FSMHandle struct {
// contains filtered or unexported fields
}
func FSM ¶ added in v0.202.0
func FSM(name string, transitions ...FSMTransition) *FSMHandle
FSM creates a new finite-state machine.
type FSMTransition ¶ added in v0.202.0
type FSMTransition struct {
// contains filtered or unexported fields
}
func Start ¶ added in v0.202.0
func Start[In any](state Sink[In]) FSMTransition
Start specifies a start state in an FSM.
func Transition ¶ added in v0.202.0
func Transition[FromIn, ToIn any](from Sink[FromIn], to Sink[ToIn]) FSMTransition
Transition specifies a transition in an FSM.
The "event" triggering the transition is the input to the "from" state.
type Handle ¶ added in v0.181.0
Handle represents a resource that can be retrieved such as a database connection, secret, etc.
type LeaseHandle ¶ added in v0.199.0
type LeaseHandle struct {
// contains filtered or unexported fields
}
func Lease ¶ added in v0.199.0
Lease acquires a new exclusive lease on a resource uniquely identified by [key].
The [ttl] defines the time after which the lease will be released if no heartbeat has been received. It must be >= 5s.
Each [key] is scoped to the module that acquires the lease.
Returns ErrLeaseHeld if the lease is already held.
func (LeaseHandle) Err ¶ added in v0.199.0
func (l LeaseHandle) Err() error
Err returns an error if the lease heartbeat fails.
func (LeaseHandle) Release ¶ added in v0.199.0
func (l LeaseHandle) Release() error
Release attempts to release the lease.
Will return an error if the heartbeat failed. In this situation there are no guarantees that the lease was held to completion.
type Logger ¶
Logger is a levelled printf-style logger with support for structured attributes.
func LoggerFromContext ¶
LoggerFromContext retrieves the current logger from the Context.
type MapHandle ¶ added in v0.181.0
type MapHandle[T, U any] struct { // contains filtered or unexported fields }
type Option ¶
type Option[T any] struct { // contains filtered or unexported fields }
An Option type is a type that can contain a value or nothing.
func Nil ¶
Nil returns an Option that is invalid if the value is nil, otherwise the value.
If the type is not nillable (slice, map, chan, ptr, interface) this will panic.
func Ptr ¶
Ptr returns an Option that is invalid if the pointer is nil, otherwise the dereferenced pointer.
func Zero ¶
Zero returns an Option that is invalid if the value is the zero value, otherwise the value.
func (Option[T]) Default ¶
func (o Option[T]) Default(value T) T
Default returns the Option value if it is present, otherwise it returns the value passed.
func (Option[T]) Get ¶
Get returns the value and a boolean indicating if the Option contains a value.
func (Option[T]) MarshalJSON ¶
func (Option[T]) MustGet ¶
func (o Option[T]) MustGet() T
MustGet returns the value. It panics if the Option contains nothing.
func (Option[T]) Ptr ¶
func (o Option[T]) Ptr() *T
Ptr returns a pointer to the value if the Option contains a value, otherwise nil.
func (*Option[T]) UnmarshalJSON ¶
type Ref ¶
Ref is an untyped reference to a symbol.
func FuncRef ¶ added in v0.194.1
FuncRef returns the Ref for a Go function.
Panics if called with a function outside FTL.
func RefFromProto ¶ added in v0.149.0
func TypeRef ¶ added in v0.194.1
TypeRef returns the Ref for a Go type.
Panics if called with a type outside of FTL.
func (*Ref) UnmarshalText ¶ added in v0.149.0
type SecretType ¶
type SecretType interface{ any }
SecretType is a type that can be used as a secret value.
type SecretValue ¶
type SecretValue[T SecretType] struct { Ref }
SecretValue is a typed secret for the current module.
func Secret ¶
func Secret[T SecretType](name string) SecretValue[T]
Secret declares a typed secret for the current module.
func (SecretValue[T]) Get ¶
func (s SecretValue[T]) Get(ctx context.Context) (out T)
Get returns the value of the secret from FTL.
func (SecretValue[T]) GoString ¶ added in v0.138.2
func (s SecretValue[T]) GoString() string
func (SecretValue[T]) String ¶
func (s SecretValue[T]) String() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package ftltest contains test utilities for the ftl package.
|
Package ftltest contains test utilities for the ftl package. |