ftl

package
v0.161.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Trace   = log.Trace
	Debug   = log.Debug
	Info    = log.Info
	Warn    = log.Warn
	Error   = log.Error
	Default = log.Default
)

Log levels.

Variables

This section is empty.

Functions

func Call

func Call[Req, Resp any](ctx context.Context, verb Verb[Req, Resp], req Req) (Resp, error)

Call a Verb through the FTL Controller.

func CallEmpty added in v0.149.2

func CallEmpty(ctx context.Context, empty Empty) error

CallEmpty calls a Verb with no request or response through the FTL controller.

func CallSink added in v0.149.2

func CallSink[Req any](ctx context.Context, sink Sink[Req], req Req) error

CallSink calls a Sink through the FTL controller.

func CallSource added in v0.149.2

func CallSource[Resp any](ctx context.Context, source Source[Resp]) (Resp, error)

CallSource calls a Source through the FTL controller.

func CallToSchemaRef added in v0.149.2

func CallToSchemaRef(call any) *schemapb.Ref

CallToSchemaRef returns the Ref for a Verb, Sink, Source, or Empty as a Schema Ref.

func PostgresDatabase

func PostgresDatabase(name string) *sql.DB

PostgresDatabase returns a Postgres database connection for the named database.

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 {
	// contains filtered or unexported fields
}

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 Empty added in v0.149.2

type Empty func(context.Context) error

An Empty is a function that does not accept input or return output.

type Logger

type Logger = log.Logger

Logger is a levelled printf-style logger with support for structured attributes.

func LoggerFromContext

func LoggerFromContext(ctx context.Context) *Logger

LoggerFromContext retrieves the current logger from the Context.

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

func Nil[T any](ptr T) Option[T]

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 None

func None[T any]() Option[T]

None returns an Option that contains nothing.

func Ptr

func Ptr[T any](ptr *T) Option[T]

Ptr returns an Option that is invalid if the pointer is nil, otherwise the dereferenced pointer.

func Some

func Some[T any](value T) Option[T]

Some returns an Option that contains a value.

func Zero

func Zero[T any](value T) Option[T]

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

func (o Option[T]) Get() (T, bool)

Get returns the value and a boolean indicating if the Option contains a value.

func (Option[T]) GoString

func (o Option[T]) GoString() string

func (Option[T]) MarshalJSON

func (o Option[T]) MarshalJSON() ([]byte, error)

func (Option[T]) MustGet

func (o Option[T]) MustGet() T

MustGet returns the value. It panics if the Option contains nothing.

func (Option[T]) Ok

func (o Option[T]) Ok() bool

Ok returns true if the Option contains a value.

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]) Scan

func (o *Option[T]) Scan(src any) error

func (Option[T]) String

func (o Option[T]) String() string

func (*Option[T]) UnmarshalJSON

func (o *Option[T]) UnmarshalJSON(data []byte) error

func (Option[T]) Value

func (o Option[T]) Value() (driver.Value, error)

type Ref

type Ref struct {
	Module string `json:"module"`
	Name   string `json:"name"`
}

Ref is an untyped reference to a symbol.

func CallToRef added in v0.149.2

func CallToRef(call any) Ref

CallToRef returns the Ref for a Verb, Sink, Source, or Empty.

func ParseRef

func ParseRef(ref string) (Ref, error)

func RefFromProto added in v0.149.0

func RefFromProto(p *schemapb.Ref) Ref

func (*Ref) String added in v0.149.0

func (v *Ref) String() string

func (*Ref) ToProto added in v0.149.0

func (v *Ref) ToProto() *schemapb.Ref

func (*Ref) UnmarshalText added in v0.149.0

func (v *Ref) UnmarshalText(text []byte) error

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 {
	// contains filtered or unexported fields
}

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

type Sink

type Sink[Req any] func(context.Context, Req) error

A Sink is a function that accepts input but returns nothing.

type Source

type Source[Resp any] func(context.Context) (Resp, error)

A Source is a function that does not accept input but returns output.

type Unit

type Unit struct{}

Unit is a type that has no value.

It can be used as a parameter or return value to indicate that a function does not accept or return any value.

type Verb

type Verb[Req, Resp any] func(context.Context, Req) (Resp, error)

A Verb is a function that accepts input and returns output.

Directories

Path Synopsis
Package ftltest contains test utilities for the ftl package.
Package ftltest contains test utilities for the ftl package.

Jump to

Keyboard shortcuts

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