Documentation
¶
Index ¶
- type Config
- type Option
- type PostgresStorage
- func (p *PostgresStorage) BulkUpsertSessions(ctx context.Context, sessions []*session.Session, preserveUpdatedAt bool) error
- func (p *PostgresStorage) Close() error
- func (p *PostgresStorage) Create(ctx context.Context, sess *session.Session) error
- func (p *PostgresStorage) Delete(ctx context.Context, sessionID string) error
- func (p *PostgresStorage) Get(ctx context.Context, sessionID string) (*session.Session, error)
- func (p *PostgresStorage) List(ctx context.Context, filters map[string]interface{}) ([]*session.Session, error)
- func (p *PostgresStorage) ListByAgent(ctx context.Context, agentID string) ([]*session.Session, error)
- func (p *PostgresStorage) ListByUser(ctx context.Context, userID string) ([]*session.Session, error)
- func (p *PostgresStorage) Update(ctx context.Context, sess *session.Session) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Schema string
Table string
BatchConfig *batch.Config
Writer batch.BatchWriter
}
Config 控制 Postgres 存储行为 Config controls Postgres storage behaviour.
type Option ¶
type Option func(*Config)
Option 是用于自定义配置的函数。 Option customises the storage configuration.
func WithBatchConfig ¶
WithBatchConfig 指定批量写入配置。
func WithBatchWriter ¶
func WithBatchWriter(writer batch.BatchWriter) Option
WithBatchWriter 指定自定义批量写入器(测试用)。
type PostgresStorage ¶
type PostgresStorage struct {
// contains filtered or unexported fields
}
PostgresStorage 实现 session.Storage,支持 JSON 字段与批量导入。
func NewStorage ¶
func NewStorage(db *sql.DB, opts ...Option) (*PostgresStorage, error)
NewStorage 创建 Postgres 存储实例。
func (*PostgresStorage) BulkUpsertSessions ¶
func (p *PostgresStorage) BulkUpsertSessions( ctx context.Context, sessions []*session.Session, preserveUpdatedAt bool, ) error
BulkUpsertSessions 批量导入 Session(迁移场景)。
func (*PostgresStorage) Delete ¶
func (p *PostgresStorage) Delete(ctx context.Context, sessionID string) error
Delete 删除 Session。
func (*PostgresStorage) List ¶
func (p *PostgresStorage) List(ctx context.Context, filters map[string]interface{}) ([]*session.Session, error)
List 查询全部 Session,支持常用过滤条件。
func (*PostgresStorage) ListByAgent ¶
func (p *PostgresStorage) ListByAgent(ctx context.Context, agentID string) ([]*session.Session, error)
ListByAgent 查询代理下的全部 Session。
func (*PostgresStorage) ListByUser ¶
func (p *PostgresStorage) ListByUser(ctx context.Context, userID string) ([]*session.Session, error)
ListByUser 查询用户下的 Session。
Click to show internal directories.
Click to hide internal directories.