Documentation
¶
Index ¶
- Constants
- type DBType
- type Database
- type DirectBehavior
- type MockBehavior
- type MockVerb
- type ModuleContext
- func (m ModuleContext) ApplyToContext(ctx context.Context) context.Context
- func (m ModuleContext) BehaviorForVerb(ref schema.Ref) (VerbBehavior, error)
- func (m ModuleContext) GetConfig(name string, value any) error
- func (m ModuleContext) GetDatabase(name string, dbType DBType) (*sql.DB, error)
- func (m ModuleContext) GetSecret(name string, value any) error
- func (m ModuleContext) ToProto() (*ftlv1.ModuleContextResponse, error)
- func (m ModuleContext) Update(configs map[string][]byte, secrets map[string][]byte, ...) ModuleContext
- func (m ModuleContext) UpdateForTesting(mockVerbs map[schema.RefKey]MockVerb, allowDirectVerbBehavior bool) ModuleContext
- func (m ModuleContext) UpdateFromEnvironment(ctx context.Context) (ModuleContext, error)
- type StandardBehavior
- type VerbBehavior
Constants ¶
const (
DBTypePostgres = DBType(ftlv1.ModuleContextResponse_POSTGRES)
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBType ¶
type DBType ftlv1.ModuleContextResponse_DBType
type DirectBehavior ¶ added in v0.196.0
type DirectBehavior struct{}
DirectBehavior indicates that the verb should be executed by calling the function directly (for testing)
type MockBehavior ¶ added in v0.196.0
type MockBehavior struct {
Mock MockVerb
}
MockBehavior indicates the verb has a mock implementation
type ModuleContext ¶
type ModuleContext struct {
// contains filtered or unexported fields
}
ModuleContext holds the context needed for a module, including configs, secrets and DSNs
func FromContext ¶ added in v0.196.0
func FromContext(ctx context.Context) ModuleContext
FromContext returns the ModuleContext attached to a context.
func FromProto ¶ added in v0.185.0
func FromProto(response *ftlv1.ModuleContextResponse) (ModuleContext, error)
func New ¶ added in v0.185.0
func New(module string) ModuleContext
New creates a new blank ModuleContext for the given module.
func (ModuleContext) ApplyToContext ¶
func (m ModuleContext) ApplyToContext(ctx context.Context) context.Context
ApplyToContext returns a Go context.Context with ModuleContext added.
func (ModuleContext) BehaviorForVerb ¶ added in v0.196.0
func (m ModuleContext) BehaviorForVerb(ref schema.Ref) (VerbBehavior, error)
BehaviorForVerb returns what to do to execute a verb
This allows module context to dictate behavior based on testing options
func (ModuleContext) GetConfig ¶ added in v0.196.0
func (m ModuleContext) GetConfig(name string, value any) error
GetConfig reads a configuration value for the module.
"value" must be a pointer to a Go type that can be unmarshalled from JSON.
func (ModuleContext) GetDatabase ¶ added in v0.196.0
GetDatabase gets a database connection
Returns an error if no database with that name is found or it is not the expected type
func (ModuleContext) GetSecret ¶ added in v0.196.0
func (m ModuleContext) GetSecret(name string, value any) error
GetSecret reads a secret value for the module.
"value" must be a pointer to a Go type that can be unmarshalled from JSON.
func (ModuleContext) ToProto ¶ added in v0.185.0
func (m ModuleContext) ToProto() (*ftlv1.ModuleContextResponse, error)
ToProto converts a ModuleContext to a proto response.
func (ModuleContext) Update ¶ added in v0.196.1
func (m ModuleContext) Update(configs map[string][]byte, secrets map[string][]byte, databases map[string]Database) ModuleContext
Update copies a ModuleContext and adds configs, secrets and databases.
func (ModuleContext) UpdateForTesting ¶ added in v0.196.1
func (m ModuleContext) UpdateForTesting(mockVerbs map[schema.RefKey]MockVerb, allowDirectVerbBehavior bool) ModuleContext
UpdateForTesting copies a ModuleContext and marks it as part of a test environment and adds mock verbs and flags for other test features.
func (ModuleContext) UpdateFromEnvironment ¶ added in v0.196.1
func (m ModuleContext) UpdateFromEnvironment(ctx context.Context) (ModuleContext, error)
UpdateFromEnvironment copies a ModuleContext and gathers configs, secrets and databases 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.
type StandardBehavior ¶ added in v0.196.0
type StandardBehavior struct{}
StandardBehavior indicates that the verb should be executed via the controller
type VerbBehavior ¶ added in v0.196.0
type VerbBehavior interface {
// contains filtered or unexported methods
}
VerbBehavior indicates how to execute a verb