Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type ConfigType
- type DatabaseConfig
- type DatabaseHandle
- type DatabaseType
- type DefaultMySQLDatabaseConfig
- type DefaultPostgresDatabaseConfig
- type Empty
- type ExternalPartitionMapper
- type Handle
- type LeaseHandle
- type Logger
- type MapHandle
- type MySQLDatabaseConfig
- 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]) Marshal(w *bytes.Buffer, encode func(v reflect.Value, w *bytes.Buffer) error) error
- 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]) Unmarshal(d *json.Decoder, isNull bool, ...) error
- func (o *Option[T]) UnmarshalJSON(data []byte) error
- func (o Option[T]) Value() (driver.Value, error)
- type PostgresDatabaseConfig
- type Secret
- type SecretType
- type SinglePartitionMap
- type Sink
- type Source
- type TopicHandle
- type TopicPartitionMap
- 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 ¶
This section is empty.
Types ¶
type Config ¶
type Config[T ConfigType] struct { reflection.Ref }
Config is a typed configuration key for the current module.
type ConfigType ¶
type ConfigType interface{ any }
ConfigType is a type that can be used as a configuration value.
type DatabaseConfig ¶
type DatabaseConfig interface { // Name returns the name of the database. Name() string // contains filtered or unexported methods }
type DatabaseHandle ¶
type DatabaseHandle[T DatabaseConfig] struct { // contains filtered or unexported fields }
func NewDatabaseHandle ¶
func NewDatabaseHandle[T DatabaseConfig](config T, dbType DatabaseType, db *once.Handle[*sql.DB]) DatabaseHandle[T]
NewDatabaseHandle is managed by FTL.
func (DatabaseHandle[T]) Get ¶
func (d DatabaseHandle[T]) Get(ctx context.Context) *sql.DB
Get returns the SQL DB connection for the database.
func (DatabaseHandle[T]) Name ¶
func (d DatabaseHandle[T]) Name() string
Name returns the name of the database.
func (DatabaseHandle[T]) String ¶
func (d DatabaseHandle[T]) String() string
String returns a string representation of the database handle.
func (DatabaseHandle[T]) Type ¶
func (d DatabaseHandle[T]) Type() DatabaseType
Type returns the type of the database, e.g. "postgres"
type DatabaseType ¶
type DatabaseType string
const ( DatabaseTypePostgres DatabaseType = "postgres" DatabaseTypeMysql DatabaseType = "mysql" )
type DefaultMySQLDatabaseConfig ¶
type DefaultMySQLDatabaseConfig struct{}
DefaultMySQLDatabaseConfig is a default implementation of MySQLDatabaseConfig. It does not provide an implementation for the Name method and should be embedded in a struct that does.
type DefaultPostgresDatabaseConfig ¶
type DefaultPostgresDatabaseConfig struct{}
DefaultPostgresDatabaseConfig is a default implementation of PostgresDatabaseConfig. It does not provide an implementation for the Name method and should be embedded in a struct that does.
type ExternalPartitionMapper ¶
type ExternalPartitionMapper[E any] struct{}
ExternalPartitionMapper is a fake partition mapper that is used to indicate that a topic is external. External topics can not be directly published to.
func (ExternalPartitionMapper[E]) PartitionKey ¶
func (ExternalPartitionMapper[E]) PartitionKey(_ E) string
type Handle ¶
Handle represents a resource that can be retrieved such as a database connection, secret, etc.
type LeaseHandle ¶
type LeaseHandle struct {
// contains filtered or unexported fields
}
func Lease ¶
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 ¶
func (l LeaseHandle) Err() error
Err returns an error if the lease heartbeat fails.
func (LeaseHandle) Release ¶
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 ¶
type MapHandle[T, U any] struct { // contains filtered or unexported fields }
type MySQLDatabaseConfig ¶
type MySQLDatabaseConfig interface { DatabaseConfig // contains filtered or unexported methods }
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 PostgresDatabaseConfig ¶
type PostgresDatabaseConfig interface { DatabaseConfig // contains filtered or unexported methods }
type Secret ¶
type Secret[T SecretType] struct { reflection.Ref }
Secret declares a typed secret for the current module.
type SecretType ¶
type SecretType interface{ any }
SecretType is a type that can be used as a secret value.
type SinglePartitionMap ¶
type SinglePartitionMap[E any] struct{}
SinglePartitionMap can be used for topics with a single partition
func (SinglePartitionMap[E]) PartitionKey ¶
func (SinglePartitionMap[E]) PartitionKey(_ E) string
type TopicHandle ¶
type TopicHandle[E any, M TopicPartitionMap[E]] struct { Ref *schema.Ref PartitionMap M }
TopicHandle accesses a topic
Topics publish events, and subscriptions can listen to them.
type TopicPartitionMap ¶
TopicPartitionMap maps an event to a partition key