storage

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupPostgresStorage

func SetupPostgresStorage(dns string) error

Types

type JSONStorage

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

func (*JSONStorage) DeleteSession

func (s *JSONStorage) DeleteSession(ctx context.Context, id string) error

func (*JSONStorage) FetchSession

func (s *JSONStorage) FetchSession(ctx context.Context, id string) (*Session, error)

func (*JSONStorage) SaveSession

func (s *JSONStorage) SaveSession(ctx context.Context, session *Session) error

func (*JSONStorage) UpdateSession

func (s *JSONStorage) UpdateSession(ctx context.Context, session *Session) error

type NoneStorage

type NoneStorage struct {
}

func (*NoneStorage) DeleteSession

func (s *NoneStorage) DeleteSession(ctx context.Context, id string) error

func (*NoneStorage) FetchSession

func (s *NoneStorage) FetchSession(ctx context.Context, id string) (*Session, error)

func (*NoneStorage) SaveSession

func (s *NoneStorage) SaveSession(ctx context.Context, session *Session) error

func (*NoneStorage) UpdateSession

func (s *NoneStorage) UpdateSession(ctx context.Context, session *Session) error

type PostgresStorage

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

func (*PostgresStorage) DeleteSession

func (s *PostgresStorage) DeleteSession(ctx context.Context, id string) error

func (*PostgresStorage) FetchSession

func (s *PostgresStorage) FetchSession(ctx context.Context, id string) (*Session, error)

func (*PostgresStorage) SaveSession

func (s *PostgresStorage) SaveSession(ctx context.Context, session *Session) error

func (*PostgresStorage) UpdateSession

func (s *PostgresStorage) UpdateSession(ctx context.Context, session *Session) error

type Session

type Session struct {
	ID         string         `json:"id" gorm:"column:id;type:bigint(20);AUTO_INCREMENT;primary_key;"` // session id
	EngineID   string         `json:"engine_id" gorm:"column:engine_id;type:varchar(255);"`            // engine id
	EngineType string         `json:"engine_type" gorm:"column:engine_type;type:varchar(255);"`        // engine type
	EngineData map[string]any `json:"engine_data" gorm:"column:engine_data;type:jsonb"`                // engine data

	Memory memory.Memory `json:"memory"` // 记忆

	CreatedAt time.Time `json:"created_at" gorm:"column:created_at;autoCreateTime"`
	UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at;autoUpdateTime"`
}

for domain usage

func NewSession

func NewSession(id string) *Session

type SessionRow

type SessionRow struct {
	ID         string         `gorm:"column:id;type:bigint(20);AUTO_INCREMENT;primary_key;"` // session id
	EngineID   string         `gorm:"column:engine_id;type:varchar(255);"`                   // engine id
	EngineType string         `gorm:"column:engine_type;type:varchar(255);"`                 // engine type
	EngineData map[string]any `gorm:"column:engine_data;type:jsonb"`                         // engine data

	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"`
}

For DB row

type Storage

type Storage interface {
	SaveSession(ctx context.Context, session *Session) error
	FetchSession(ctx context.Context, id string) (*Session, error)
	UpdateSession(ctx context.Context, session *Session) error
	DeleteSession(ctx context.Context, id string) error
}

func NewJSONStorage

func NewJSONStorage(path string) Storage

func NewPostgresStorage

func NewPostgresStorage(db *sql.DB) Storage

func NewPostgresStorageWithDNS

func NewPostgresStorageWithDNS(dns string) Storage

func NewPostgresStorageWithGormDB

func NewPostgresStorageWithGormDB(gormDB *gorm.DB) Storage

Jump to

Keyboard shortcuts

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