storage

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const SortDirectionKey = "sort_direction"

Variables

View Source
var ConfigFs embed.FS
View Source
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) Count added in v0.11.0

func (s *CosmosDBAdapter) Count(dest any, filter map[string]any, params ...map[string]any) (int64, error)

func (*CosmosDBAdapter) CountContext added in v0.17.0

func (s *CosmosDBAdapter) CountContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) (int64, error)

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 (s *CosmosDBAdapter) CreateContext(ctx context.Context, item any, params ...map[string]any) error

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) Delete added in v0.11.0

func (s *CosmosDBAdapter) Delete(item any, filter map[string]any, params ...map[string]any) error

func (*CosmosDBAdapter) DeleteContext added in v0.17.0

func (s *CosmosDBAdapter) DeleteContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error

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) Get added in v0.11.0

func (s *CosmosDBAdapter) Get(dest any, filter map[string]any, params ...map[string]any) error

func (*CosmosDBAdapter) GetContext added in v0.17.0

func (s *CosmosDBAdapter) GetContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) error

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) List added in v0.11.0

func (s *CosmosDBAdapter) List(dest any, sortKey string, filter map[string]any, limit int, cursor string, params ...map[string]any) (string, error)

func (*CosmosDBAdapter) ListContext added in v0.17.0

func (s *CosmosDBAdapter) ListContext(ctx context.Context, dest any, sortKey string, filter map[string]any, limit int, cursor string, params ...map[string]any) (string, error)

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) Query added in v0.11.0

func (s *CosmosDBAdapter) Query(dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)

func (*CosmosDBAdapter) QueryContext added in v0.17.0

func (s *CosmosDBAdapter) QueryContext(ctx context.Context, dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)

func (*CosmosDBAdapter) Search added in v0.11.0

func (s *CosmosDBAdapter) Search(dest any, sortKey string, query string, limit int, cursor string, params ...map[string]any) (string, error)

func (*CosmosDBAdapter) SearchContext added in v0.17.0

func (s *CosmosDBAdapter) SearchContext(ctx context.Context, dest any, sortKey string, query string, limit int, cursor string, params ...map[string]any) (string, error)

func (*CosmosDBAdapter) Update added in v0.11.0

func (s *CosmosDBAdapter) Update(item any, filter map[string]any, params ...map[string]any) error

func (*CosmosDBAdapter) UpdateContext added in v0.17.0

func (s *CosmosDBAdapter) UpdateContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error

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

type DynamoDBAdapter struct {
	DB *dynamodb.Client
	// contains filtered or unexported fields
}

func GetDynamoDBAdapterInstance

func GetDynamoDBAdapterInstance(config map[string]string) *DynamoDBAdapter

func (*DynamoDBAdapter) Count added in v0.6.0

func (s *DynamoDBAdapter) Count(dest any, filter map[string]any, params ...map[string]any) (int64, error)

func (*DynamoDBAdapter) CountContext added in v0.17.0

func (s *DynamoDBAdapter) CountContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) (int64, error)

func (*DynamoDBAdapter) Create

func (s *DynamoDBAdapter) Create(item any, params ...map[string]any) error

func (*DynamoDBAdapter) CreateContext added in v0.17.0

func (s *DynamoDBAdapter) CreateContext(ctx context.Context, item any, params ...map[string]any) error

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) Delete

func (s *DynamoDBAdapter) Delete(item any, filter map[string]any, params ...map[string]any) error

func (*DynamoDBAdapter) DeleteContext added in v0.17.0

func (s *DynamoDBAdapter) DeleteContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error

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) Get

func (s *DynamoDBAdapter) Get(dest any, filter map[string]any, params ...map[string]any) error

func (*DynamoDBAdapter) GetContext added in v0.17.0

func (s *DynamoDBAdapter) GetContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) error

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) List

func (s *DynamoDBAdapter) List(dest any, sortKey string, filter map[string]any, limit int, cursor string, params ...map[string]any) (string, error)

func (*DynamoDBAdapter) ListContext added in v0.17.0

func (s *DynamoDBAdapter) ListContext(ctx context.Context, dest any, sortKey string, filter map[string]any, limit int, cursor string, params ...map[string]any) (string, error)

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) Query added in v0.7.0

func (s *DynamoDBAdapter) Query(dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)

func (*DynamoDBAdapter) QueryContext added in v0.17.0

func (s *DynamoDBAdapter) QueryContext(ctx context.Context, dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)

func (*DynamoDBAdapter) Search added in v0.6.0

func (s *DynamoDBAdapter) Search(dest any, sortKey string, query string, limit int, cursor string, params ...map[string]any) (string, error)

func (*DynamoDBAdapter) SearchContext added in v0.17.0

func (s *DynamoDBAdapter) SearchContext(ctx context.Context, dest any, sortKey string, query string, limit int, cursor string, params ...map[string]any) (string, error)

func (*DynamoDBAdapter) Update

func (s *DynamoDBAdapter) Update(item any, filter map[string]any, params ...map[string]any) error

func (*DynamoDBAdapter) UpdateContext added in v0.17.0

func (s *DynamoDBAdapter) UpdateContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error

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) Count added in v0.6.0

func (m *MemoryAdapter) Count(dest any, filter map[string]any, params ...map[string]any) (int64, error)

func (*MemoryAdapter) CountContext added in v0.17.0

func (m *MemoryAdapter) CountContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) (int64, error)

func (*MemoryAdapter) Create

func (m *MemoryAdapter) Create(item any, params ...map[string]any) error

func (*MemoryAdapter) CreateContext added in v0.17.0

func (m *MemoryAdapter) CreateContext(ctx context.Context, item any, params ...map[string]any) error

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) Delete

func (m *MemoryAdapter) Delete(item any, filter map[string]any, params ...map[string]any) error

func (*MemoryAdapter) DeleteContext added in v0.17.0

func (m *MemoryAdapter) DeleteContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error

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) Get

func (m *MemoryAdapter) Get(dest any, filter map[string]any, params ...map[string]any) error

func (*MemoryAdapter) GetContext added in v0.17.0

func (m *MemoryAdapter) GetContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) error

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) List

func (m *MemoryAdapter) List(dest any, sortKey string, filter map[string]any, limit int, cursor string, params ...map[string]any) (string, error)

func (*MemoryAdapter) ListContext added in v0.17.0

func (m *MemoryAdapter) ListContext(ctx context.Context, dest any, sortKey string, filter map[string]any, limit int, cursor string, params ...map[string]any) (string, error)

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) Query added in v0.7.0

func (m *MemoryAdapter) Query(dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)

func (*MemoryAdapter) QueryContext added in v0.17.0

func (m *MemoryAdapter) QueryContext(ctx context.Context, dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)

func (*MemoryAdapter) Search added in v0.6.0

func (m *MemoryAdapter) Search(dest any, sortKey string, query string, limit int, cursor string, params ...map[string]any) (string, error)

func (*MemoryAdapter) SearchContext added in v0.17.0

func (m *MemoryAdapter) SearchContext(ctx context.Context, dest any, sortKey string, query string, limit int, cursor string, params ...map[string]any) (string, error)

func (*MemoryAdapter) Update

func (m *MemoryAdapter) Update(item any, filter map[string]any, params ...map[string]any) error

func (*MemoryAdapter) UpdateContext added in v0.17.0

func (m *MemoryAdapter) UpdateContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error

func (*MemoryAdapter) UpdateMigrationTable added in v0.9.1

func (m *MemoryAdapter) UpdateMigrationTable(id int, name string, desc string) error

type Migration

type Migration struct {
	Migrate  string
	Rollback string
}

type MigrationFile

type MigrationFile struct {
	Description string
	Migrations  []Migration
}

type SQLAdapter

type SQLAdapter struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

func GetSQLAdapterInstance

func GetSQLAdapterInstance(config map[string]string) *SQLAdapter

func (*SQLAdapter) Count added in v0.6.0

func (s *SQLAdapter) Count(dest any, filter map[string]any, params ...map[string]any) (int64, error)

func (*SQLAdapter) CountContext added in v0.17.0

func (s *SQLAdapter) CountContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) (int64, error)

func (*SQLAdapter) Create

func (s *SQLAdapter) Create(item any, params ...map[string]any) error

func (*SQLAdapter) CreateContext added in v0.17.0

func (s *SQLAdapter) CreateContext(ctx context.Context, item any, params ...map[string]any) error

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) Delete

func (s *SQLAdapter) Delete(item any, filter map[string]any, params ...map[string]any) error

func (*SQLAdapter) DeleteContext added in v0.17.0

func (s *SQLAdapter) DeleteContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error

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) Get

func (s *SQLAdapter) Get(dest any, filter map[string]any, params ...map[string]any) error

func (*SQLAdapter) GetContext added in v0.17.0

func (s *SQLAdapter) GetContext(ctx context.Context, dest any, filter map[string]any, params ...map[string]any) error

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) List

func (s *SQLAdapter) List(dest any, sortKey string, filter map[string]any, limit int, cursor string, params ...map[string]any) (string, error)

func (*SQLAdapter) ListContext added in v0.17.0

func (s *SQLAdapter) ListContext(ctx context.Context, dest any, sortKey string, filter map[string]any, limit int, cursor string, params ...map[string]any) (string, error)

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) Query added in v0.7.0

func (s *SQLAdapter) Query(dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)

func (*SQLAdapter) QueryContext added in v0.17.0

func (s *SQLAdapter) QueryContext(ctx context.Context, dest any, statement string, limit int, cursor string, params ...map[string]any) (string, error)

func (*SQLAdapter) Search added in v0.6.0

func (s *SQLAdapter) Search(dest any, sortKey string, query string, limit int, cursor string, params ...map[string]any) (string, error)

func (*SQLAdapter) SearchContext added in v0.17.0

func (s *SQLAdapter) SearchContext(ctx context.Context, dest any, sortKey string, query string, limit int, cursor string, params ...map[string]any) (string, error)

func (*SQLAdapter) Update

func (s *SQLAdapter) Update(item any, filter map[string]any, params ...map[string]any) error

func (*SQLAdapter) UpdateContext added in v0.17.0

func (s *SQLAdapter) UpdateContext(ctx context.Context, item any, filter map[string]any, params ...map[string]any) error

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()
}

Directories

Path Synopsis
search

Jump to

Keyboard shortcuts

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