Documentation ¶
Index ¶
Constants ¶
const (
DBTypePostgres = DBType(ftlv1.ModuleContextResponse_POSTGRES)
)
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.
type DBType ¶
type DBType ftlv1.ModuleContextResponse_DBType
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
func (m *ModuleContext) ToProto(ctx context.Context) (*ftlv1.ModuleContextResponse, error)
ToProto converts a ModuleContext to a proto response.