Documentation
¶
Overview ¶
Package storage provides a configuration-driven registry for physical storage backends. Logical stores can build scoped views on top of these backend instances.
Index ¶
- Constants
- func ValidateRedisURL(raw string) error
- func ValidateTiKVConfig(cfg TiKVConfig) error
- type AliyunOSSConfig
- type AzureBlobConfig
- type BadgerConfig
- type ClickHouseConfig
- type Config
- type ConfigError
- type FilesystemDirConfig
- type GCSConfig
- type Memory
- type MemoryConfig
- type PostgreSQLConfig
- type PrometheusConfig
- type RedisConfig
- type RedisReadWriteConfig
- type SQLiteConfig
- type Storage
- func (s *Storage) AliyunOSS(name string) (*oss.Bucket, error)
- func (s *Storage) AzureBlob(name string) (*azblob.Client, string, error)
- func (s *Storage) Badger(name string) (*badger.DB, error)
- func (s *Storage) Close() error
- func (s *Storage) FilesystemDir(name string) (*os.Root, error)
- func (s *Storage) GCS(name string) (*gcs.Client, string, error)
- func (s *Storage) Kind(name string) (string, error)
- func (s *Storage) Memory(name string) (Memory, error)
- func (s *Storage) Prometheus(name string) (api.Client, string, error)
- func (s *Storage) Redis(name string) (*redis.Client, error)
- func (s *Storage) RedisReadWrite(name string) (read, write *redis.Client, err error)
- func (s *Storage) SQL(name string) (*sqlx.DB, error)
- func (s *Storage) TiKV(name string) (*tikv.KVStore, TiKVConfig, error)
- func (s *Storage) VolcTLS(name string) (tls.Client, error)
- func (s *Storage) VolcTOS(name string) (*tos.ClientV2, string, error)
- type TiKVConfig
- type VolcTLSConfig
- type VolcTOSConfig
Constants ¶
const ( KindBadger = "badger" KindMemory = "memory" KindFilesystemDir = "filesystem.dir" KindSQLite = "sqlite" KindPostgreSQL = "postgresql" KindClickHouse = "clickhouse" KindTiKV = "tikv" KindRedis = "redis" KindRedisReadWrite = "redis.readwrite" KindPrometheus = "prometheus" KindVolcTLS = "volc-tls" KindVolcTOS = "volc-tos" KindAliyunOSS = "aliyun-oss" KindGCS = "gcs" KindAzureBlob = "azure-blob" )
Kind constants identify concrete physical storage backends in external configuration. Programmatic callers select a backend with the matching concrete Config implementation instead of setting a Kind field.
Variables ¶
This section is empty.
Functions ¶
func ValidateRedisURL ¶ added in v0.12.1
ValidateRedisURL applies the same single-node URL and TLS requirements used when Storage opens Redis, without reading CA files or connecting to Redis.
func ValidateTiKVConfig ¶ added in v0.33.0
func ValidateTiKVConfig(cfg TiKVConfig) error
ValidateTiKVConfig checks addresses and read/TLS settings without network I/O.
Types ¶
type AliyunOSSConfig ¶ added in v0.4.0
type AliyunOSSConfig struct {
Endpoint string
Bucket string
AccessKeyID string
AccessKeySecret string
SecurityToken string
}
AliyunOSSConfig configures one Alibaba Cloud OSS bucket.
type AzureBlobConfig ¶ added in v0.4.0
AzureBlobConfig configures one Azure Blob Storage container.
type BadgerConfig ¶
type BadgerConfig struct {
Dir string
}
BadgerConfig configures one physical Badger database.
type ClickHouseConfig ¶
type ClickHouseConfig struct {
DSN string
}
ClickHouseConfig configures one ClickHouse connection pool.
type Config ¶
type Config interface {
// contains filtered or unexported methods
}
Config is a closed set of physical backend configurations accepted by New. Each implementation exposes only fields meaningful to that backend.
type ConfigError ¶
ConfigError identifies the physical storage entry whose construction failed.
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
Error preserves the underlying construction error text.
func (*ConfigError) Unwrap ¶
func (e *ConfigError) Unwrap() error
Unwrap exposes the underlying construction error.
type FilesystemDirConfig ¶
type FilesystemDirConfig struct {
Dir string
}
FilesystemDirConfig configures one rooted filesystem directory.
type Memory ¶
type Memory struct{}
Memory marks a process-local physical slot. Logical Store constructors use the marker to create independent in-memory backends.
type MemoryConfig ¶
type MemoryConfig struct{}
MemoryConfig declares a process-local Storage slot. It has no physical resource or configurable properties.
type PostgreSQLConfig ¶
PostgreSQLConfig configures one PostgreSQL connection pool. The pool keeps up to MaxOpenConns idle sessions for reuse and releases idle sessions after ConnMaxIdleTime. Zero values select 128 connections and one minute; negative values are invalid. Additional connections are opened on demand.
type PrometheusConfig ¶
PrometheusConfig configures one Prometheus API client and its remote-write endpoint.
type RedisConfig ¶ added in v0.8.3
RedisConfig configures one single-node Redis connection. TLSCAFile adds trusted PEM certificates for rediss URLs.
type RedisReadWriteConfig ¶ added in v0.31.9
type RedisReadWriteConfig struct {
Read RedisConfig
Write RedisConfig
}
RedisReadWriteConfig configures independent Redis read and write connections. Both endpoints must address the same logical database in one replication group. The caller owns replication and a stable writable primary endpoint.
type SQLiteConfig ¶
SQLiteConfig configures one SQLite database using exactly one of Dir or DSN.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage owns physical backend instances and configured memory markers.
func New ¶
New creates a Storage registry, validates every configured physical backend, and opens stateful resources. Process-local memory roots remain lazy because their concrete type is selected by the consuming Store contract. Dir fields are used as provided by the caller.
func (*Storage) AliyunOSS ¶ added in v0.4.0
AliyunOSS returns the named physical Alibaba Cloud OSS bucket client.
func (*Storage) AzureBlob ¶ added in v0.4.0
AzureBlob returns the named physical Azure Blob client and container.
func (*Storage) FilesystemDir ¶
FilesystemDir returns the named rooted filesystem handle.
func (*Storage) GCS ¶ added in v0.4.0
GCS returns the named physical Google Cloud Storage client and bucket.
func (*Storage) Prometheus ¶
Prometheus returns the named API client and validated remote-write URL.
func (*Storage) Redis ¶ added in v0.8.3
Redis returns the named physical Redis client. The Storage registry owns the client and closes it with the other physical resources.
func (*Storage) RedisReadWrite ¶ added in v0.31.9
RedisReadWrite returns the named read and write Redis clients, in that order. The Storage registry owns both clients and closes them with its other resources.
func (*Storage) TiKV ¶ added in v0.33.0
TiKV returns a borrowed transactional client and its read configuration. Storage owns the client's lifetime. Returned configuration maps are copies.
type TiKVConfig ¶ added in v0.33.0
type TiKVConfig struct {
PDAddresses []string
TLSCAFile string
TLSCertFile string
TLSKeyFile string
// Deprecated: ignored. ReadLabels alone enables native Learner reads.
// No fixed snapshot delay is applied.
StaleReadDelay time.Duration
ReadLabels map[string]string
}
TiKVConfig configures a transactional TiKV cluster discovered through PD. ReadLabels restricts ordinary data reads to matching Learners using native replica-read synchronization. Empty labels keep ordinary reads strong. Strong reads and all mutations always use fresh leader transactions. TLS files apply to PD, its etcd endpoint, and TiKV RPCs.