Documentation
¶
Index ¶
- func WithDynamORM(config *DynamORMConfig, optionalFactory ...DBFactory) lift.Middleware
- type DBFactory
- type DefaultDBFactory
- type DynamORMConfig
- type DynamORMWrapper
- func (d *DynamORMWrapper) BeginTransaction() (*Transaction, error)
- func (d *DynamORMWrapper) Delete(ctx context.Context, key any) error
- func (d *DynamORMWrapper) Get(ctx context.Context, key any, result any) error
- func (d *DynamORMWrapper) GetCoreDB() core.DB
- func (d *DynamORMWrapper) Put(ctx context.Context, item any) error
- func (d *DynamORMWrapper) Query(ctx context.Context, query *Query) (*QueryResult, error)
- func (d *DynamORMWrapper) WithTenant(tenantID string) *DynamORMWrapper
- type MockDBFactory
- type Query
- type QueryResult
- type Transaction
- type TransactionOperation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithDynamORM ¶
func WithDynamORM(config *DynamORMConfig, optionalFactory ...DBFactory) lift.Middleware
WithDynamORM creates middleware that provides DynamORM integration
Types ¶
type DBFactory ¶
type DBFactory interface {
CreateDB(config session.Config) (core.ExtendedDB, error)
}
DBFactory interface for creating DynamORM instances
type DefaultDBFactory ¶
type DefaultDBFactory struct{}
DefaultDBFactory creates real DynamORM instances
func (*DefaultDBFactory) CreateDB ¶
func (f *DefaultDBFactory) CreateDB(config session.Config) (core.ExtendedDB, error)
type DynamORMConfig ¶
type DynamORMConfig struct {
// Table configuration
TableName string `json:"table_name"`
Region string `json:"region"`
Endpoint string `json:"endpoint,omitempty"` // For local testing
// Connection settings
MaxRetries int `json:"max_retries"`
Timeout time.Duration `json:"timeout"`
// Transaction settings
AutoTransaction bool `json:"auto_transaction"` // Automatically wrap writes in transactions
// Multi-tenant settings
TenantIsolation bool `json:"tenant_isolation"` // Enforce tenant-based data isolation
TenantKey string `json:"tenant_key"` // Key used for tenant isolation (default: "tenant_id")
// Performance settings
ConsistentRead bool `json:"consistent_read"` // Use strongly consistent reads
BatchSize int `json:"batch_size"` // Default batch size for operations
}
DynamORMConfig holds configuration for DynamORM integration
func DefaultConfig ¶
func DefaultConfig() *DynamORMConfig
DefaultConfig returns a default DynamORM configuration
type DynamORMWrapper ¶
type DynamORMWrapper struct {
// contains filtered or unexported fields
}
DynamORMWrapper wraps the DynamORM client with Lift-specific functionality
func DB ¶
func DB(ctx *lift.Context) (*DynamORMWrapper, error)
DB retrieves the DynamORM instance from the context
func TenantDB ¶
func TenantDB(ctx *lift.Context) (*DynamORMWrapper, error)
TenantDB retrieves the tenant-scoped DynamORM instance from the context
func (*DynamORMWrapper) BeginTransaction ¶
func (d *DynamORMWrapper) BeginTransaction() (*Transaction, error)
BeginTransaction starts a new transaction using DynamORM
func (*DynamORMWrapper) Delete ¶
func (d *DynamORMWrapper) Delete(ctx context.Context, key any) error
Delete removes an item using DynamORM
func (*DynamORMWrapper) GetCoreDB ¶
func (d *DynamORMWrapper) GetCoreDB() core.DB
GetCoreDB returns the underlying core.DB for use with other libraries
func (*DynamORMWrapper) Put ¶
func (d *DynamORMWrapper) Put(ctx context.Context, item any) error
Put saves an item using DynamORM
func (*DynamORMWrapper) Query ¶
func (d *DynamORMWrapper) Query(ctx context.Context, query *Query) (*QueryResult, error)
Query performs a query operation using DynamORM
func (*DynamORMWrapper) WithTenant ¶
func (d *DynamORMWrapper) WithTenant(tenantID string) *DynamORMWrapper
WithTenant creates a tenant-scoped wrapper
type MockDBFactory ¶
type MockDBFactory struct {
MockDB core.ExtendedDB
Error error
OnCreateDB func(config session.Config)
}
MockDBFactory creates mock DynamORM instances for testing
func NewMockDBFactory ¶
func NewMockDBFactory() *MockDBFactory
NewMockDBFactory creates a factory with a MockExtendedDB
func (*MockDBFactory) CreateDB ¶
func (f *MockDBFactory) CreateDB(config session.Config) (core.ExtendedDB, error)
type Query ¶
type Query struct {
PartitionKey any
SortKey any
IndexName string
Filters map[string]any
Limit int
Ascending bool
}
Query represents a DynamORM query
type QueryResult ¶
QueryResult represents the result of a query operation
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction represents a DynamORM transaction
func (*Transaction) Commit ¶
func (t *Transaction) Commit() error
Commit commits the transaction using DynamORM
func (*Transaction) Delete ¶
func (t *Transaction) Delete(ctx context.Context, key any) error
Delete adds a delete operation to the transaction
func (*Transaction) Put ¶
func (t *Transaction) Put(ctx context.Context, item any) error
Put adds a put operation to the transaction
func (*Transaction) Rollback ¶
func (t *Transaction) Rollback() error
Rollback rolls back the transaction using DynamORM
type TransactionOperation ¶
TransactionOperation represents an operation to be executed in a transaction