tgstorage

package
v0.0.0-...-e65fbe1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltSession

type BoltSession struct {
	kv.Session
}

BoltSession wraps kv.Session for BoltDB backend

func NewBoltSession

func NewBoltSession(db *bbolt.DB, key string) *BoltSession

NewBoltSession creates a new BoltDB-backed session

type BoltStorage

type BoltStorage struct {
	// contains filtered or unexported fields
}

BoltStorage implements session storage using BoltDB Uses a single file with separate buckets for different sessions

func NewBoltStorage

func NewBoltStorage(cfg config.BoltSessionConfig, key string) (*BoltStorage, error)

NewBoltStorage creates a new BoltDB session storage

func (*BoltStorage) Close

func (s *BoltStorage) Close() error

Close closes the BoltDB database

func (*BoltStorage) LoadSession

func (s *BoltStorage) LoadSession(ctx context.Context) ([]byte, error)

LoadSession retrieves session data from BoltDB

func (*BoltStorage) StoreSession

func (s *BoltStorage) StoreSession(ctx context.Context, data []byte) error

StoreSession saves session data to BoltDB

func (*BoltStorage) Type

func (s *BoltStorage) Type() string

Type returns the storage type

type KeyValue

type KeyValue struct {
	Key       string    `gorm:"type:text;primaryKey"`
	Value     []byte    `gorm:"type:bytea;not null"`
	CreatedAt time.Time `gorm:"default:timezone('utc'::text, now())"`
}

func (KeyValue) TableName

func (KeyValue) TableName() string

type MemoryStorage

type MemoryStorage struct {
	// contains filtered or unexported fields
}

MemoryStorage implements session storage using in-memory storage This is suitable for development/testing only - data is lost on restart

func NewMemoryStorage

func NewMemoryStorage() *MemoryStorage

NewMemoryStorage creates a new in-memory session storage

func (*MemoryStorage) Close

func (s *MemoryStorage) Close() error

Close is a no-op for memory storage

func (*MemoryStorage) LoadSession

func (s *MemoryStorage) LoadSession(ctx context.Context) ([]byte, error)

LoadSession retrieves session data from memory

func (*MemoryStorage) StoreSession

func (s *MemoryStorage) StoreSession(ctx context.Context, data []byte) error

StoreSession saves session data to memory

func (*MemoryStorage) Type

func (s *MemoryStorage) Type() string

Type returns the storage type

type PeerStorage

type PeerStorage struct {
	// contains filtered or unexported fields
}

func NewPeerStorage

func NewPeerStorage(kvRepo repositories.KVRepository, prefix string) *PeerStorage

func (PeerStorage) Add

func (s PeerStorage) Add(ctx context.Context, value storage.Peer) error

func (PeerStorage) Assign

func (s PeerStorage) Assign(ctx context.Context, key string, value storage.Peer) error

func (PeerStorage) Delete

func (s PeerStorage) Delete(ctx context.Context, key storage.PeerKey) error

func (PeerStorage) Find

func (PeerStorage) Iterate

func (PeerStorage) Purge

func (s PeerStorage) Purge(ctx context.Context) error

func (PeerStorage) Resolve

func (s PeerStorage) Resolve(ctx context.Context, key string) (storage.Peer, error)

type PostgresSession

type PostgresSession struct {
	kv.Session
}

PostgresSession wraps kv.Session for PostgreSQL backend with cache

func NewPostgresSession

func NewPostgresSession(kvRepo repositories.KVRepository, cache cache.Cacher, key string) *PostgresSession

NewPostgresSession creates a new PostgreSQL-backed session with optional caching

type PostgresStorage

type PostgresStorage struct {
	// contains filtered or unexported fields
}

PostgresStorage implements session storage using repository KV storage

func NewPostgresStorage

func NewPostgresStorage(kvRepo repositories.KVRepository, cache cache.Cacher, key string) *PostgresStorage

NewPostgresStorage creates a new PostgreSQL-backed session storage with caching

func (*PostgresStorage) Close

func (s *PostgresStorage) Close() error

Close is a no-op for PostgreSQL storage (connection managed elsewhere)

func (*PostgresStorage) LoadSession

func (s *PostgresStorage) LoadSession(ctx context.Context) ([]byte, error)

LoadSession retrieves session data from PostgreSQL with caching

func (*PostgresStorage) StoreSession

func (s *PostgresStorage) StoreSession(ctx context.Context, data []byte) error

StoreSession saves session data to PostgreSQL

func (*PostgresStorage) Type

func (s *PostgresStorage) Type() string

Type returns the storage type

type Storage

type Storage interface {
	session.Storage // LoadSession, StoreSession

	// Type returns the storage backend type
	Type() string

	// Close closes the storage backend
	Close() error
}

Storage defines the interface for all session storage backends It wraps gotd/td/session.Storage with additional lifecycle methods

func NewSessionStorage

func NewSessionStorage(cfg config.SessionStorageConfig, kvRepo repositories.KVRepository, cache cache.Cacher, key string) (Storage, error)

NewSessionStorage creates a session storage based on configuration key identifies the specific session (e.g., userID, bot token) cache is used for PostgreSQL storage to reduce DB reads

Jump to

Keyboard shortcuts

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