sdk

package
v0.101.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

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

Call a Verb through the FTL Controller.

func PostgresDatabase added in v0.97.0

func PostgresDatabase(name string) *sql.DB

PostgresDatabase returns a Postgres database connection for the named database.

Types

type AbstractRef added in v0.93.0

type AbstractRef[Proto schema.RefProto] Ref

AbstractRef is an abstract reference to a symbol.

func ParseRef added in v0.93.0

func ParseRef[Proto schema.RefProto](ref string) (AbstractRef[Proto], error)

func (*AbstractRef[Proto]) String added in v0.93.0

func (v *AbstractRef[Proto]) String() string

func (*AbstractRef[Proto]) ToProto added in v0.93.0

func (v *AbstractRef[Proto]) ToProto() *Proto

func (*AbstractRef[Proto]) UnmarshalText added in v0.93.0

func (v *AbstractRef[Proto]) UnmarshalText(text []byte) error

type Any added in v0.100.0

type Any = any

Any is a generic type that can hold any value.

type ConfigType added in v0.96.0

type ConfigType interface {
	string | int | float64 | bool |
		[]string | []int | []float64 | []bool | []byte |
		map[string]string | map[string]int | map[string]float64 | map[string]bool | map[string][]byte
}

ConfigType is a type that can be used as a configuration value.

Supported types are currently limited, but will eventually be extended to allow any type that FTL supports, including structs.

type ConfigValue added in v0.96.0

type ConfigValue[T ConfigType] struct {
	// contains filtered or unexported fields
}

ConfigValue is a typed configuration key for the current module.

func Config added in v0.96.0

func Config[T ConfigType](name string) ConfigValue[T]

Config declares a typed configuration key for the current module.

func (*ConfigValue[T]) Get added in v0.96.0

func (c *ConfigValue[T]) Get() (out T)

Get returns the value of the configuration key from FTL.

func (*ConfigValue[T]) String added in v0.96.0

func (c *ConfigValue[T]) String() string

type DataRef

type DataRef = AbstractRef[schemapb.DataRef]

DataRef is a reference to a Data type.

func DataRefFromProto

func DataRefFromProto(p *schemapb.DataRef) DataRef

func ParseDataRef

func ParseDataRef(ref string) (DataRef, error)

type Option added in v0.78.0

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

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

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

None returns an Option that contains nothing.

func Ptr added in v0.78.0

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

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

Some returns an Option that contains a value.

func Zero added in v0.78.0

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

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

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

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

func (Option[T]) MarshalJSON added in v0.78.0

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

func (Option[T]) MustGet added in v0.78.0

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

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

func (Option[T]) Ok added in v0.78.0

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

Ok returns true if the Option contains a value.

func (Option[T]) Ptr added in v0.78.0

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

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

func (Option[T]) String added in v0.78.0

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

func (*Option[T]) UnmarshalJSON added in v0.78.0

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

func (Option[T]) Value added in v0.78.0

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

type Ref added in v0.93.0

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

Ref is an untyped reference to a symbol.

type SecretType added in v0.96.0

type SecretType interface {
	string | int | float64 | bool |
		[]string | []int | []float64 | []bool | []byte |
		map[string]string | map[string]int | map[string]float64 | map[string]bool | map[string][]byte
}

SecretType is a type that can be used as a secret value.

Supported types are currently limited, but will eventually be extended to allow any type that FTL supports, including structs.

type SecretValue added in v0.96.0

type SecretValue[Type SecretType] struct {
	// contains filtered or unexported fields
}

SecretValue is a typed secret for the current module.

func Secret added in v0.96.0

func Secret[Type SecretType](name string) SecretValue[Type]

Secret declares a typed secret for the current module.

func (*SecretValue[Type]) Get added in v0.96.0

func (s *SecretValue[Type]) Get() (out Type)

Get returns the value of the secret from FTL.

func (*SecretValue[Type]) String added in v0.96.0

func (s *SecretValue[Type]) 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 SinkRef added in v0.93.0

type SinkRef = AbstractRef[schemapb.SinkRef]

func ParseSinkRef added in v0.93.0

func ParseSinkRef(ref string) (SinkRef, error)

func SinkRefFromProto added in v0.93.0

func SinkRefFromProto(p *schemapb.SinkRef) SinkRef

func SinkToRef added in v0.93.0

func SinkToRef[Req any](sink Sink[Req]) SinkRef

type Source added in v0.93.0

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

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

type SourceRef added in v0.93.0

type SourceRef = AbstractRef[schemapb.SourceRef]

func ParseSourceRef added in v0.93.0

func ParseSourceRef(ref string) (SourceRef, error)

func SourceRefFromProto added in v0.93.0

func SourceRefFromProto(p *schemapb.SourceRef) SourceRef

type Unit added in v0.94.0

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.

type VerbRef

type VerbRef = AbstractRef[schemapb.VerbRef]

VerbRef is a reference to a verb (a function in the form F(I)O).

func ParseVerbRef

func ParseVerbRef(ref string) (VerbRef, error)

func VerbRefFromProto

func VerbRefFromProto(p *schemapb.VerbRef) VerbRef

func VerbToRef added in v0.93.0

func VerbToRef[Req, Resp any](verb Verb[Req, Resp]) VerbRef

VerbToRef returns the FTL reference for a Verb.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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