Documentation
¶
Index ¶
- Variables
- func RegisterServiceBinding(name string, serviceBindingBuilder ServiceBindingBuilder)
- type PostgresContextKey
- type PostgresServiceBinding
- func (b *PostgresServiceBinding) ApplyGrants(ctx context.Context, account map[string]string, ...) ([]types.BindingGrant, error)
- func (b *PostgresServiceBinding) BeginTransaction(ctx context.Context) (context.Context, error)
- func (b *PostgresServiceBinding) CloseService(ctx context.Context) error
- func (b *PostgresServiceBinding) CommitTransaction(ctx context.Context) error
- func (b *PostgresServiceBinding) GenerateAccount(ctx context.Context, bindingId, bindingPath string, ...) (map[string]string, error)
- func (b *PostgresServiceBinding) InitializeService(ctx context.Context, logger *types.Logger, serviceConfig map[string]string) error
- func (b *PostgresServiceBinding) RollbackTransaction(ctx context.Context) error
- func (b *PostgresServiceBinding) RunCommand(ctx context.Context, bindingMetadata types.BindingMetadata, command string) (map[string]any, error)
- type ServiceBinding
- type ServiceBindingBuilder
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ServiceBindings = map[string]ServiceBindingBuilder{}
)
Functions ¶
func RegisterServiceBinding ¶
func RegisterServiceBinding(name string, serviceBindingBuilder ServiceBindingBuilder)
RegisterServiceBinding registers a service binding
Types ¶
type PostgresContextKey ¶ added in v0.17.3
type PostgresContextKey string
const POSTGRES_TRANSACTION_KEY PostgresContextKey = "postgres_sb_transaction"
type PostgresServiceBinding ¶
func (*PostgresServiceBinding) ApplyGrants ¶ added in v0.17.3
func (b *PostgresServiceBinding) ApplyGrants(ctx context.Context, account map[string]string, bindingMetadata types.BindingMetadata, derivedFromMetadata types.BindingMetadata, reapplyAll bool) ([]types.BindingGrant, error)
func (*PostgresServiceBinding) BeginTransaction ¶ added in v0.17.3
func (*PostgresServiceBinding) CloseService ¶ added in v0.17.4
func (b *PostgresServiceBinding) CloseService(ctx context.Context) error
func (*PostgresServiceBinding) CommitTransaction ¶ added in v0.17.3
func (b *PostgresServiceBinding) CommitTransaction(ctx context.Context) error
func (*PostgresServiceBinding) GenerateAccount ¶
func (b *PostgresServiceBinding) GenerateAccount(ctx context.Context, bindingId, bindingPath string, bindingMetadata types.BindingMetadata, derivedFromMetadata *types.BindingMetadata, isStaging bool) (map[string]string, error)
func (*PostgresServiceBinding) InitializeService ¶ added in v0.17.3
func (*PostgresServiceBinding) RollbackTransaction ¶ added in v0.17.3
func (b *PostgresServiceBinding) RollbackTransaction(ctx context.Context) error
func (*PostgresServiceBinding) RunCommand ¶ added in v0.17.4
func (b *PostgresServiceBinding) RunCommand(ctx context.Context, bindingMetadata types.BindingMetadata, command string) (map[string]any, error)
type ServiceBinding ¶
type ServiceBinding interface {
// Initialize the service with the given config. This is called when the service binding is created.
InitializeService(ctx context.Context, logger *types.Logger, serviceConfig map[string]string) error
// Close the service connection. This is called when the service binding is no longer needed.
CloseService(ctx context.Context) error
// Begin a new transaction. This is called when the binding is created, before the account is generated.
// The transaction is used to generate the account and apply the grants. The transaction is expected to be saved in the context.
// The connection used for the transaction is the admin connection to the main database, not the binding account connection.
BeginTransaction(ctx context.Context) (context.Context, error)
// Commit the transaction.
CommitTransaction(ctx context.Context) error
// Rollback the transaction.
RollbackTransaction(ctx context.Context) error
// Generate the account based on the binding config. This is called once when the binding is created, after the service is initialized.
// The account is created on the endpoint specified in the service config.
GenerateAccount(ctx context.Context, bindingId, bindingPath string, bindingMetadata types.BindingMetadata,
derivedFromMetadata *types.BindingMetadata, isStaging bool) (map[string]string, error)
// Apply the grants to the account. This is called when the binding is created, after the account is generated.
// The grants are applied to the account on the endpoint specified in the service config. It can be called again if the grants are changed.
ApplyGrants(ctx context.Context, account map[string]string,
bindingMetadata, derivedFromMetadata types.BindingMetadata, reapplyAll bool) ([]types.BindingGrant, error)
// Run a command on the endpoint specified in the service config as the binding account.
RunCommand(ctx context.Context, bindingMetadata types.BindingMetadata, command string) (map[string]any, error)
}
func NewPostgresServiceBinding ¶
func NewPostgresServiceBinding() ServiceBinding
type ServiceBindingBuilder ¶
type ServiceBindingBuilder func() ServiceBinding
Click to show internal directories.
Click to hide internal directories.