modulecontext

package
v0.185.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

Variables

This section is empty.

Functions

func ContextWithDBProvider

func ContextWithDBProvider(ctx context.Context, provider *DBProvider) context.Context

Types

type DBProvider

type DBProvider struct {
	// contains filtered or unexported fields
}

DBProvider takes in DSNs and holds a *sql.DB for each this allows us to: - pool db connections, rather than initializing anew each time - validate DSNs at startup, rather than returning errors or panicking at Database.Get()

func DBProviderFromContext

func DBProviderFromContext(ctx context.Context) *DBProvider

func NewDBProvider

func NewDBProvider() *DBProvider

func NewDBProviderFromEnvironment added in v0.185.0

func NewDBProviderFromEnvironment(module string) (*DBProvider, error)

NewDBProviderFromEnvironment creates a new DBProvider from environment variables.

This is a temporary measure until we have a way to load DSNs from the ftl-project.toml file.

func (*DBProvider) Add

func (d *DBProvider) Add(name string, dbType DBType, dsn string) error

func (*DBProvider) Get

func (d *DBProvider) Get(name string) (*sql.DB, error)

type DBType

func (DBType) String

func (x DBType) String() string

type ModuleContext

type ModuleContext struct {
	// contains filtered or unexported fields
}

ModuleContext holds the context needed for a module, including configs, secrets and DSNs

func FromEnvironment added in v0.185.0

func FromEnvironment(ctx context.Context, module string) (*ModuleContext, error)

FromEnvironment creates a ModuleContext from the local environment.

This is useful for testing and development, where the environment is used to provide configurations, secrets and DSNs. The context is built from a combination of the ftl-project.toml file and (for now) environment variables.

func FromProto added in v0.185.0

func FromProto(ctx context.Context, response *ftlv1.ModuleContextResponse) (*ModuleContext, error)

func New added in v0.185.0

func New(module string, cm *cf.Manager[cf.Configuration], sm *cf.Manager[cf.Secrets], dbp *DBProvider) *ModuleContext

func (*ModuleContext) ApplyToContext

func (m *ModuleContext) ApplyToContext(ctx context.Context) context.Context

ApplyToContext returns a Go context.Context that includes configurations, secrets and DSNs can be retreived Each of these components have accessors to get a manager back from the context

func (*ModuleContext) ToProto added in v0.185.0

ToProto converts a ModuleContext to a proto response.

Jump to

Keyboard shortcuts

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