Documentation
¶
Index ¶
- Constants
- Variables
- type ContextualStorageAdapter
- type CosmosDBAdapter
- func (s *CosmosDBAdapter) Count(dest any, filter map[string]any, params ...map[string]any) (int64, error)
- func (s *CosmosDBAdapter) CountContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) (int64, error)
- func (s *CosmosDBAdapter) Create(item any, params ...map[string]any) error
- func (s *CosmosDBAdapter) CreateContext(ctx context.Context, item any, params ...map[string]any) error
- func (s *CosmosDBAdapter) CreateMigrationTable() error
- func (s *CosmosDBAdapter) CreateSchema() error
- func (s *CosmosDBAdapter) Delete(item any, filter map[string]any, params ...map[string]any) error
- func (s *CosmosDBAdapter) DeleteContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error
- func (s *CosmosDBAdapter) Execute(statement string) error
- func (s *CosmosDBAdapter) ExecuteContext(ctx context.Context, statement string) error
- func (s *CosmosDBAdapter) Get(dest any, filter map[string]any, params ...map[string]any) error
- func (s *CosmosDBAdapter) GetContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) error
- func (s *CosmosDBAdapter) GetLatestMigration() (int, error)
- func (s *CosmosDBAdapter) GetProvider() StorageProviders
- func (s *CosmosDBAdapter) GetSchemaName() string
- func (s *CosmosDBAdapter) GetType() StorageAdapterType
- func (s *CosmosDBAdapter) List(dest any, sortKey string, filter map[string]any, limit int, cursor string, ...) (string, error)
- func (s *CosmosDBAdapter) ListContext(ctx context.Context, dest any, sortKey string, filter map[string]any, ...) (string, error)
- func (s *CosmosDBAdapter) OpenConnection()
- func (s *CosmosDBAdapter) Ping() error
- func (s *CosmosDBAdapter) PingContext(ctx context.Context) error
- func (s *CosmosDBAdapter) Query(dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)
- func (s *CosmosDBAdapter) QueryContext(ctx context.Context, dest any, statement string, limit int, cursor string, ...) (string, error)
- func (s *CosmosDBAdapter) Search(dest any, sortKey string, query string, limit int, cursor string, ...) (string, error)
- func (s *CosmosDBAdapter) SearchContext(ctx context.Context, dest any, sortKey string, query string, limit int, ...) (string, error)
- func (s *CosmosDBAdapter) Update(item any, filter map[string]any, params ...map[string]any) error
- func (s *CosmosDBAdapter) UpdateContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error
- func (s *CosmosDBAdapter) UpdateMigrationTable(id int, name string, desc string) error
- type DatabaseMigration
- type DynamoDBAdapter
- func (s *DynamoDBAdapter) Count(dest any, filter map[string]any, params ...map[string]any) (int64, error)
- func (s *DynamoDBAdapter) CountContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) (int64, error)
- func (s *DynamoDBAdapter) Create(item any, params ...map[string]any) error
- func (s *DynamoDBAdapter) CreateContext(ctx context.Context, item any, params ...map[string]any) error
- func (s *DynamoDBAdapter) CreateMigrationTable() error
- func (s *DynamoDBAdapter) CreateSchema() error
- func (s *DynamoDBAdapter) Delete(item any, filter map[string]any, params ...map[string]any) error
- func (s *DynamoDBAdapter) DeleteContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error
- func (s *DynamoDBAdapter) Execute(statement string) error
- func (s *DynamoDBAdapter) ExecuteContext(ctx context.Context, statement string) error
- func (s *DynamoDBAdapter) Get(dest any, filter map[string]any, params ...map[string]any) error
- func (s *DynamoDBAdapter) GetContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) error
- func (s *DynamoDBAdapter) GetLatestMigration() (int, error)
- func (s *DynamoDBAdapter) GetProvider() StorageProviders
- func (s *DynamoDBAdapter) GetSchemaName() string
- func (s *DynamoDBAdapter) GetType() StorageAdapterType
- func (s *DynamoDBAdapter) List(dest any, sortKey string, filter map[string]any, limit int, cursor string, ...) (string, error)
- func (s *DynamoDBAdapter) ListContext(ctx context.Context, dest any, sortKey string, filter map[string]any, ...) (string, error)
- func (s *DynamoDBAdapter) OpenConnection()
- func (s *DynamoDBAdapter) Ping() error
- func (s *DynamoDBAdapter) PingContext(ctx context.Context) error
- func (s *DynamoDBAdapter) Query(dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)
- func (s *DynamoDBAdapter) QueryContext(ctx context.Context, dest any, statement string, limit int, cursor string, ...) (string, error)
- func (s *DynamoDBAdapter) Search(dest any, sortKey string, query string, limit int, cursor string, ...) (string, error)
- func (s *DynamoDBAdapter) SearchContext(ctx context.Context, dest any, sortKey string, query string, limit int, ...) (string, error)
- func (s *DynamoDBAdapter) Update(item any, filter map[string]any, params ...map[string]any) error
- func (s *DynamoDBAdapter) UpdateContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error
- func (s *DynamoDBAdapter) UpdateMigrationTable(id int, name string, desc string) error
- type MemoryAdapter
- func (m *MemoryAdapter) Count(dest any, filter map[string]any, params ...map[string]any) (int64, error)
- func (m *MemoryAdapter) CountContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) (int64, error)
- func (m *MemoryAdapter) Create(item any, params ...map[string]any) error
- func (m *MemoryAdapter) CreateContext(ctx context.Context, item any, params ...map[string]any) error
- func (m *MemoryAdapter) CreateMigrationTable() error
- func (m *MemoryAdapter) CreateSchema() error
- func (m *MemoryAdapter) Delete(item any, filter map[string]any, params ...map[string]any) error
- func (m *MemoryAdapter) DeleteContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error
- func (m *MemoryAdapter) Execute(s string) error
- func (m *MemoryAdapter) ExecuteContext(ctx context.Context, s string) error
- func (m *MemoryAdapter) Get(dest any, filter map[string]any, params ...map[string]any) error
- func (m *MemoryAdapter) GetContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) error
- func (m *MemoryAdapter) GetLatestMigration() (int, error)
- func (m *MemoryAdapter) GetProvider() StorageProviders
- func (m *MemoryAdapter) GetSchemaName() string
- func (m *MemoryAdapter) GetType() StorageAdapterType
- func (m *MemoryAdapter) List(dest any, sortKey string, filter map[string]any, limit int, cursor string, ...) (string, error)
- func (m *MemoryAdapter) ListContext(ctx context.Context, dest any, sortKey string, filter map[string]any, ...) (string, error)
- func (m *MemoryAdapter) Ping() error
- func (m *MemoryAdapter) PingContext(ctx context.Context) error
- func (m *MemoryAdapter) Query(dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)
- func (m *MemoryAdapter) QueryContext(ctx context.Context, dest any, statement string, limit int, cursor string, ...) (string, error)
- func (m *MemoryAdapter) Search(dest any, sortKey string, query string, limit int, cursor string, ...) (string, error)
- func (m *MemoryAdapter) SearchContext(ctx context.Context, dest any, sortKey string, query string, limit int, ...) (string, error)
- func (m *MemoryAdapter) Update(item any, filter map[string]any, params ...map[string]any) error
- func (m *MemoryAdapter) UpdateContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error
- func (m *MemoryAdapter) UpdateMigrationTable(id int, name string, desc string) error
- type Migration
- type MigrationFile
- type SQLAdapter
- func (s *SQLAdapter) Count(dest any, filter map[string]any, params ...map[string]any) (int64, error)
- func (s *SQLAdapter) CountContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) (int64, error)
- func (s *SQLAdapter) Create(item any, params ...map[string]any) error
- func (s *SQLAdapter) CreateContext(ctx context.Context, item any, params ...map[string]any) error
- func (s *SQLAdapter) CreateMigrationTable() error
- func (s *SQLAdapter) CreateSchema() error
- func (s *SQLAdapter) Delete(item any, filter map[string]any, params ...map[string]any) error
- func (s *SQLAdapter) DeleteContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error
- func (s *SQLAdapter) Execute(statement string) error
- func (s *SQLAdapter) ExecuteContext(ctx context.Context, statement string) error
- func (s *SQLAdapter) Get(dest any, filter map[string]any, params ...map[string]any) error
- func (s *SQLAdapter) GetContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) error
- func (s *SQLAdapter) GetLatestMigration() (int, error)
- func (s *SQLAdapter) GetProvider() StorageProviders
- func (s *SQLAdapter) GetSchemaName() string
- func (s *SQLAdapter) GetType() StorageAdapterType
- func (s *SQLAdapter) List(dest any, sortKey string, filter map[string]any, limit int, cursor string, ...) (string, error)
- func (s *SQLAdapter) ListContext(ctx context.Context, dest any, sortKey string, filter map[string]any, ...) (string, error)
- func (s *SQLAdapter) OpenConnection()
- func (s *SQLAdapter) Ping() error
- func (s *SQLAdapter) PingContext(ctx context.Context) error
- func (s *SQLAdapter) Query(dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)
- func (s *SQLAdapter) QueryContext(ctx context.Context, dest any, statement string, limit int, cursor string, ...) (string, error)
- func (s *SQLAdapter) Search(dest any, sortKey string, query string, limit int, cursor string, ...) (string, error)
- func (s *SQLAdapter) SearchContext(ctx context.Context, dest any, sortKey string, query string, limit int, ...) (string, error)
- func (s *SQLAdapter) Update(item any, filter map[string]any, params ...map[string]any) error
- func (s *SQLAdapter) UpdateContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error
- func (s *SQLAdapter) UpdateMigrationTable(id int, name string, desc string) error
- type SortingDirection
- type StorageAdapter
- type StorageAdapterFactory
- type StorageAdapterType
- type StorageProviders
- type TelemetryUnwrapper
Constants ¶
const SortDirectionKey = "sort_direction"
Variables ¶
var ConfigFs embed.FS
var ErrNotFound = errors.New("the requested resource was not found")
Functions ¶
This section is empty.
Types ¶
type ContextualStorageAdapter ¶ added in v0.17.0
type ContextualStorageAdapter interface {
StorageAdapter
ExecuteContext(ctx context.Context, statement string) error
PingContext(ctx context.Context) error
CreateContext(ctx context.Context, item any, params ...map[string]any) error
GetContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) error
UpdateContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error
DeleteContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error
ListContext(ctx context.Context, dest any, sortKey string, filter map[string]any, limit int, cursor string, params ...map[string]any) (string, error)
SearchContext(ctx context.Context, dest any, sortKey string, query string, limit int, cursor string, params ...map[string]any) (string, error)
CountContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) (int64, error)
QueryContext(ctx context.Context, dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)
}
ContextualStorageAdapter is an extension interface that adds a context-aware sibling to every request-path I/O operation on StorageAdapter. Adapters shipped in the magic repository implement both interfaces; the non-Context methods delegate to the Context variants with context.Background(). Third-party adapters are free to implement only StorageAdapter, in which case the instrumented wrapper falls back to metrics-only coverage (see wrapForTelemetry).
Note: schema/migration methods (CreateSchema, CreateMigrationTable, UpdateMigrationTable, GetLatestMigration) intentionally do NOT have Context variants. They are one-shot startup operations that run before any request-scoped context exists, they are not part of any distributed trace, and their failures already surface as fatal startup errors. Adding Context variants for them would be pure surface-area churn.
type CosmosDBAdapter ¶ added in v0.11.0
type CosmosDBAdapter struct {
// contains filtered or unexported fields
}
func GetCosmosDBAdapterInstance ¶ added in v0.11.0
func GetCosmosDBAdapterInstance(config map[string]string) *CosmosDBAdapter
func (*CosmosDBAdapter) CountContext ¶ added in v0.17.0
func (*CosmosDBAdapter) Create ¶ added in v0.11.0
func (s *CosmosDBAdapter) Create(item any, params ...map[string]any) error
func (*CosmosDBAdapter) CreateContext ¶ added in v0.17.0
func (*CosmosDBAdapter) CreateMigrationTable ¶ added in v0.11.0
func (s *CosmosDBAdapter) CreateMigrationTable() error
func (*CosmosDBAdapter) CreateSchema ¶ added in v0.11.0
func (s *CosmosDBAdapter) CreateSchema() error
func (*CosmosDBAdapter) DeleteContext ¶ added in v0.17.0
func (*CosmosDBAdapter) Execute ¶ added in v0.11.0
func (s *CosmosDBAdapter) Execute(statement string) error
func (*CosmosDBAdapter) ExecuteContext ¶ added in v0.17.0
func (s *CosmosDBAdapter) ExecuteContext(ctx context.Context, statement string) error
func (*CosmosDBAdapter) GetContext ¶ added in v0.17.0
func (*CosmosDBAdapter) GetLatestMigration ¶ added in v0.11.0
func (s *CosmosDBAdapter) GetLatestMigration() (int, error)
func (*CosmosDBAdapter) GetProvider ¶ added in v0.11.0
func (s *CosmosDBAdapter) GetProvider() StorageProviders
func (*CosmosDBAdapter) GetSchemaName ¶ added in v0.11.0
func (s *CosmosDBAdapter) GetSchemaName() string
func (*CosmosDBAdapter) GetType ¶ added in v0.11.0
func (s *CosmosDBAdapter) GetType() StorageAdapterType
func (*CosmosDBAdapter) ListContext ¶ added in v0.17.0
func (*CosmosDBAdapter) OpenConnection ¶ added in v0.11.0
func (s *CosmosDBAdapter) OpenConnection()
func (*CosmosDBAdapter) Ping ¶ added in v0.11.0
func (s *CosmosDBAdapter) Ping() error
func (*CosmosDBAdapter) PingContext ¶ added in v0.17.0
func (s *CosmosDBAdapter) PingContext(ctx context.Context) error
func (*CosmosDBAdapter) QueryContext ¶ added in v0.17.0
func (*CosmosDBAdapter) SearchContext ¶ added in v0.17.0
func (*CosmosDBAdapter) UpdateContext ¶ added in v0.17.0
func (*CosmosDBAdapter) UpdateMigrationTable ¶ added in v0.11.0
func (s *CosmosDBAdapter) UpdateMigrationTable(id int, name string, desc string) error
type DatabaseMigration ¶
type DatabaseMigration struct {
// contains filtered or unexported fields
}
func NewDatabaseMigration ¶
func NewDatabaseMigration(storageAdapter StorageAdapter) *DatabaseMigration
func (*DatabaseMigration) Migrate ¶
func (m *DatabaseMigration) Migrate()
type DynamoDBAdapter ¶
func GetDynamoDBAdapterInstance ¶
func GetDynamoDBAdapterInstance(config map[string]string) *DynamoDBAdapter
func (*DynamoDBAdapter) CountContext ¶ added in v0.17.0
func (*DynamoDBAdapter) Create ¶
func (s *DynamoDBAdapter) Create(item any, params ...map[string]any) error
func (*DynamoDBAdapter) CreateContext ¶ added in v0.17.0
func (*DynamoDBAdapter) CreateMigrationTable ¶ added in v0.9.1
func (s *DynamoDBAdapter) CreateMigrationTable() error
func (*DynamoDBAdapter) CreateSchema ¶ added in v0.9.1
func (s *DynamoDBAdapter) CreateSchema() error
func (*DynamoDBAdapter) DeleteContext ¶ added in v0.17.0
func (*DynamoDBAdapter) Execute ¶
func (s *DynamoDBAdapter) Execute(statement string) error
func (*DynamoDBAdapter) ExecuteContext ¶ added in v0.17.0
func (s *DynamoDBAdapter) ExecuteContext(ctx context.Context, statement string) error
func (*DynamoDBAdapter) GetContext ¶ added in v0.17.0
func (*DynamoDBAdapter) GetLatestMigration ¶ added in v0.9.1
func (s *DynamoDBAdapter) GetLatestMigration() (int, error)
func (*DynamoDBAdapter) GetProvider ¶ added in v0.3.0
func (s *DynamoDBAdapter) GetProvider() StorageProviders
func (*DynamoDBAdapter) GetSchemaName ¶ added in v0.3.0
func (s *DynamoDBAdapter) GetSchemaName() string
func (*DynamoDBAdapter) GetType ¶ added in v0.3.0
func (s *DynamoDBAdapter) GetType() StorageAdapterType
func (*DynamoDBAdapter) ListContext ¶ added in v0.17.0
func (*DynamoDBAdapter) OpenConnection ¶
func (s *DynamoDBAdapter) OpenConnection()
func (*DynamoDBAdapter) Ping ¶
func (s *DynamoDBAdapter) Ping() error
func (*DynamoDBAdapter) PingContext ¶ added in v0.17.0
func (s *DynamoDBAdapter) PingContext(ctx context.Context) error
func (*DynamoDBAdapter) QueryContext ¶ added in v0.17.0
func (*DynamoDBAdapter) SearchContext ¶ added in v0.17.0
func (*DynamoDBAdapter) UpdateContext ¶ added in v0.17.0
func (*DynamoDBAdapter) UpdateMigrationTable ¶ added in v0.9.1
func (s *DynamoDBAdapter) UpdateMigrationTable(id int, name string, desc string) error
type MemoryAdapter ¶
type MemoryAdapter struct {
DB *SQLAdapter
}
MemoryAdapter provides an in-memory SQLite-backed store. It implements ContextualStorageAdapter; all *Context methods delegate to the embedded SQLAdapter so request-scoped context matches production SQL behavior.
func GetMemoryAdapterInstance ¶
func GetMemoryAdapterInstance() *MemoryAdapter
func (*MemoryAdapter) CountContext ¶ added in v0.17.0
func (*MemoryAdapter) Create ¶
func (m *MemoryAdapter) Create(item any, params ...map[string]any) error
func (*MemoryAdapter) CreateContext ¶ added in v0.17.0
func (*MemoryAdapter) CreateMigrationTable ¶ added in v0.9.1
func (m *MemoryAdapter) CreateMigrationTable() error
func (*MemoryAdapter) CreateSchema ¶ added in v0.9.1
func (m *MemoryAdapter) CreateSchema() error
func (*MemoryAdapter) DeleteContext ¶ added in v0.17.0
func (*MemoryAdapter) Execute ¶
func (m *MemoryAdapter) Execute(s string) error
func (*MemoryAdapter) ExecuteContext ¶ added in v0.17.0
func (m *MemoryAdapter) ExecuteContext(ctx context.Context, s string) error
func (*MemoryAdapter) GetContext ¶ added in v0.17.0
func (*MemoryAdapter) GetLatestMigration ¶ added in v0.9.1
func (m *MemoryAdapter) GetLatestMigration() (int, error)
func (*MemoryAdapter) GetProvider ¶ added in v0.3.0
func (m *MemoryAdapter) GetProvider() StorageProviders
func (*MemoryAdapter) GetSchemaName ¶ added in v0.3.0
func (m *MemoryAdapter) GetSchemaName() string
func (*MemoryAdapter) GetType ¶ added in v0.3.0
func (m *MemoryAdapter) GetType() StorageAdapterType
func (*MemoryAdapter) ListContext ¶ added in v0.17.0
func (*MemoryAdapter) Ping ¶
func (m *MemoryAdapter) Ping() error
func (*MemoryAdapter) PingContext ¶ added in v0.17.0
func (m *MemoryAdapter) PingContext(ctx context.Context) error
func (*MemoryAdapter) QueryContext ¶ added in v0.17.0
func (*MemoryAdapter) SearchContext ¶ added in v0.17.0
func (*MemoryAdapter) UpdateContext ¶ added in v0.17.0
func (*MemoryAdapter) UpdateMigrationTable ¶ added in v0.9.1
func (m *MemoryAdapter) UpdateMigrationTable(id int, name string, desc string) error
type MigrationFile ¶
type SQLAdapter ¶
func GetSQLAdapterInstance ¶
func GetSQLAdapterInstance(config map[string]string) *SQLAdapter
func (*SQLAdapter) CountContext ¶ added in v0.17.0
func (*SQLAdapter) CreateContext ¶ added in v0.17.0
func (*SQLAdapter) CreateMigrationTable ¶ added in v0.9.1
func (s *SQLAdapter) CreateMigrationTable() error
func (*SQLAdapter) CreateSchema ¶ added in v0.9.1
func (s *SQLAdapter) CreateSchema() error
func (*SQLAdapter) DeleteContext ¶ added in v0.17.0
func (*SQLAdapter) Execute ¶
func (s *SQLAdapter) Execute(statement string) error
func (*SQLAdapter) ExecuteContext ¶ added in v0.17.0
func (s *SQLAdapter) ExecuteContext(ctx context.Context, statement string) error
func (*SQLAdapter) GetContext ¶ added in v0.17.0
func (*SQLAdapter) GetLatestMigration ¶ added in v0.9.1
func (s *SQLAdapter) GetLatestMigration() (int, error)
func (*SQLAdapter) GetProvider ¶ added in v0.3.0
func (s *SQLAdapter) GetProvider() StorageProviders
func (*SQLAdapter) GetSchemaName ¶ added in v0.3.0
func (s *SQLAdapter) GetSchemaName() string
func (*SQLAdapter) GetType ¶ added in v0.3.0
func (s *SQLAdapter) GetType() StorageAdapterType
func (*SQLAdapter) ListContext ¶ added in v0.17.0
func (*SQLAdapter) OpenConnection ¶
func (s *SQLAdapter) OpenConnection()
func (*SQLAdapter) Ping ¶
func (s *SQLAdapter) Ping() error
func (*SQLAdapter) PingContext ¶ added in v0.17.0
func (s *SQLAdapter) PingContext(ctx context.Context) error
func (*SQLAdapter) QueryContext ¶ added in v0.17.0
func (*SQLAdapter) SearchContext ¶ added in v0.17.0
func (*SQLAdapter) UpdateContext ¶ added in v0.17.0
func (*SQLAdapter) UpdateMigrationTable ¶ added in v0.9.1
func (s *SQLAdapter) UpdateMigrationTable(id int, name string, desc string) error
type SortingDirection ¶ added in v0.14.0
type SortingDirection string
const ( Ascending SortingDirection = "ASC" Descending SortingDirection = "DESC" )
type StorageAdapter ¶
type StorageAdapter interface {
Execute(statement string) error
Ping() error
GetType() StorageAdapterType
GetProvider() StorageProviders
GetSchemaName() string
CreateSchema() error
CreateMigrationTable() error
UpdateMigrationTable(id int, name string, desc string) error
GetLatestMigration() (int, error)
Create(item any, params ...map[string]any) error
Get(dest any, filter map[string]any, params ...map[string]any) error
Update(item any, filter map[string]any, params ...map[string]any) error
Delete(item any, filter map[string]any, params ...map[string]any) error
// List returns a page of items matching filter, ordered by sortKey.
// sortKey must be the JSON/column name (e.g. "created_at"), not the Go struct field name.
// Pass SortDirectionKey via params to control order; defaults to Ascending.
// Returns a cursor for the next page, or "" on the final page.
List(dest any, sortKey string, filter map[string]any, limit int, cursor string, params ...map[string]any) (string, error)
// Search returns a page of items matching a Lucene query string, ordered by sortKey.
// sortKey must be the JSON/column name (e.g. "created_at"), not the Go struct field name.
// Pass SortDirectionKey via params to control order; defaults to Ascending.
// Returns a cursor for the next page, or "" on the final page.
Search(dest any, sortKey string, query string, limit int, cursor string, params ...map[string]any) (string, error)
Count(dest any, filter map[string]any, params ...map[string]any) (int64, error)
Query(dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)
}
func UnwrapAdapter ¶ added in v0.17.0
func UnwrapAdapter(s StorageAdapter) StorageAdapter
UnwrapAdapter returns the inner StorageAdapter when s is (directly or transitively) the telemetry instrumented wrapper used by magic; otherwise it returns s unchanged.
Call this before type assertions to concrete adapter implementations (for example *SQLAdapter, *MemoryAdapter, *DynamoDBAdapter), including before registering GORM plugins or accessing embedded *gorm.DB, when the adapter may have been wrapped after global telemetry was initialized.
type StorageAdapterFactory ¶
type StorageAdapterFactory struct{}
func (StorageAdapterFactory) GetInstance ¶
func (s StorageAdapterFactory) GetInstance(adapterType StorageAdapterType, config any) (StorageAdapter, error)
GetInstance constructs the requested storage adapter and wraps it with the telemetry instrumented adapter from wrapForTelemetry. Callers that need the concrete implementation (for example *SQLAdapter to register a GORM plugin) must use UnwrapAdapter first (see also TelemetryUnwrapper); otherwise type assertions to *SQLAdapter fail when the wrapper sits in front.
type StorageAdapterType ¶
type StorageAdapterType string
const ( // CASSANDRA StorageAdapterType = "cassandra" COSMOSDB StorageAdapterType = "cosmosdb" DYNAMODB StorageAdapterType = "dynamodb" MEMORY StorageAdapterType = "memory" SQL StorageAdapterType = "sql" )
type StorageProviders ¶
type StorageProviders string
const ( POSTGRESQL StorageProviders = "postgresql" MYSQL StorageProviders = "mysql" SQLITE StorageProviders = "sqlite" COSMOSDB_PROVIDER StorageProviders = "cosmosdb" )
type TelemetryUnwrapper ¶ added in v0.17.0
type TelemetryUnwrapper interface {
UnwrapStorageAdapter() StorageAdapter
}
TelemetryUnwrapper is implemented by the instrumented adapter returned from StorageAdapterFactory.GetInstance after observability instrumentation wraps storage. Call UnwrapStorageAdapter to peel one telemetry layer (similar to errors.Unwrap), or use UnwrapAdapter for all nested wrappers in one step.
Typical use when you must reach the concrete type—for example to register a GORM plugin with sql.DB.Use—otherwise type assertions such as s.(*SQLAdapter) fail because s is the wrapper, not *SQLAdapter:
inner := storage.UnwrapAdapter(s) sqlAdapter := inner.(*storage.SQLAdapter) sqlAdapter.DB.Use(plugin)
Or peel a single layer with:
if u, ok := s.(storage.TelemetryUnwrapper); ok {
_ = u.UnwrapStorageAdapter()
}