bindings

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

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

type PostgresServiceBinding struct {
	*types.Logger
	// contains filtered or unexported fields
}

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 (b *PostgresServiceBinding) BeginTransaction(ctx context.Context) (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 (b *PostgresServiceBinding) InitializeService(ctx context.Context, logger *types.Logger, serviceConfig map[string]string) error

func (*PostgresServiceBinding) RollbackTransaction added in v0.17.3

func (b *PostgresServiceBinding) RollbackTransaction(ctx context.Context) 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

	// 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.
	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)
}

func NewPostgresServiceBinding

func NewPostgresServiceBinding() ServiceBinding

type ServiceBindingBuilder

type ServiceBindingBuilder func() ServiceBinding

Jump to

Keyboard shortcuts

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