Documentation
¶
Index ¶
- Variables
- func Version() string
- type AIProvider
- type AppLog
- type ColumnInfo
- type Config
- type HttpCli
- func (c *HttpCli) Create(cfg *Config) *HttpCli
- func (c *HttpCli) Delete(url string, options Options) (*Response, error)
- func (c *HttpCli) Do(method, path string, opt Options) (*Response, error)
- func (c *HttpCli) DownloadFileWithResume(url string, filepath string, progressCallback func(int64, int64)) error
- func (c *HttpCli) Get(url string, options Options) (*Response, error)
- func (c *HttpCli) GetCaptchaImage(path string) (string, error)
- func (c *HttpCli) Head(url string, options Options) (*Response, error)
- func (c *HttpCli) Options(url string, options Options) (*Response, error)
- func (c *HttpCli) Patch(url string, options Options) (*Response, error)
- func (c *HttpCli) Post(url string, options Options) (*Response, error)
- func (c *HttpCli) PostStream(path string, options Options) (*http.Response, error)
- func (c *HttpCli) Put(url string, options Options) (*Response, error)
- func (c *HttpCli) UseRequestInterceptor(interceptors ...RequestInterceptor)
- func (c *HttpCli) UseResponseInterceptor(interceptors ...ResponseInterceptor)
- type IStore
- type ITransaction
- type LocalStore
- func (l *LocalStore) AddColumn(tableName, columnDef string) error
- func (l *LocalStore) BeginTx() (ITransaction, error)
- func (l *LocalStore) Close() error
- func (l *LocalStore) CreateTable(tableName string, schema string) error
- func (l *LocalStore) Delete(key string) error
- func (l *LocalStore) DropTable(tableName string) error
- func (l *LocalStore) Exec(query string, args ...interface{}) (sql.Result, error)
- func (l *LocalStore) Expire(key string, milliseconds int64) error
- func (l *LocalStore) Get(key string) (string, error)
- func (l *LocalStore) GetTableSchema(tableName string) ([]ColumnInfo, error)
- func (l *LocalStore) HDel(key string, fields ...string) error
- func (l *LocalStore) HExists(key, field string) (bool, error)
- func (l *LocalStore) HGet(key, field string) (string, error)
- func (l *LocalStore) HGetAll(key string) (map[string]string, error)
- func (l *LocalStore) HKeys(key string) ([]string, error)
- func (l *LocalStore) HLen(key string) (int, error)
- func (l *LocalStore) HMGet(key string, fields ...string) ([]string, error)
- func (l *LocalStore) HMSet(key string, fieldValue map[string]string) error
- func (l *LocalStore) HSet(key, field, value string) error
- func (l *LocalStore) LLen(key string) (int, error)
- func (l *LocalStore) LPop(key string) (string, error)
- func (l *LocalStore) LPush(key string, values ...string) error
- func (l *LocalStore) LRange(key string, start, stop int) ([]string, error)
- func (l *LocalStore) List() (map[string]string, error)
- func (l *LocalStore) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (l *LocalStore) QueryRow(query string, args ...interface{}) *sql.Row
- func (l *LocalStore) RPop(key string) (string, error)
- func (l *LocalStore) RPush(key string, values ...string) error
- func (l *LocalStore) SAdd(key string, members ...string) error
- func (l *LocalStore) SCard(key string) (int, error)
- func (l *LocalStore) SIsMember(key, member string) (bool, error)
- func (l *LocalStore) SMembers(key string) ([]string, error)
- func (l *LocalStore) SRem(key string, members ...string) error
- func (l *LocalStore) Set(key, value string) error
- func (l *LocalStore) TTL(key string) (int64, error)
- func (l *LocalStore) TableExists(tableName string) (bool, error)
- type LoggerOption
- type MemStore
- func (m *MemStore) AddColumn(tableName, columnDef string) error
- func (m *MemStore) BeginTx() (ITransaction, error)
- func (m *MemStore) Close() error
- func (m *MemStore) CreateTable(tableName string, schema string) error
- func (m *MemStore) Delete(key string) error
- func (m *MemStore) DropTable(tableName string) error
- func (m *MemStore) Exec(query string, args ...interface{}) (sql.Result, error)
- func (m *MemStore) Expire(key string, milliseconds int64) error
- func (m *MemStore) Get(key string) (string, error)
- func (m *MemStore) GetTableSchema(tableName string) ([]ColumnInfo, error)
- func (m *MemStore) HDel(key string, fields ...string) error
- func (m *MemStore) HExists(key, field string) (bool, error)
- func (m *MemStore) HGet(key, field string) (string, error)
- func (m *MemStore) HGetAll(key string) (map[string]string, error)
- func (m *MemStore) HKeys(key string) ([]string, error)
- func (m *MemStore) HLen(key string) (int, error)
- func (m *MemStore) HMGet(key string, fields ...string) ([]string, error)
- func (m *MemStore) HMSet(key string, fieldValue map[string]string) error
- func (m *MemStore) HSet(key, field, value string) error
- func (m *MemStore) LLen(key string) (int, error)
- func (m *MemStore) LPop(key string) (string, error)
- func (m *MemStore) LPush(key string, values ...string) error
- func (m *MemStore) LRange(key string, start, stop int) ([]string, error)
- func (m *MemStore) List() (map[string]string, error)
- func (m *MemStore) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (m *MemStore) QueryRow(query string, args ...interface{}) *sql.Row
- func (m *MemStore) RPop(key string) (string, error)
- func (m *MemStore) RPush(key string, values ...string) error
- func (m *MemStore) SAdd(key string, members ...string) error
- func (m *MemStore) SCard(key string) (int, error)
- func (m *MemStore) SIsMember(key, member string) (bool, error)
- func (m *MemStore) SMembers(key string) ([]string, error)
- func (m *MemStore) SRem(key string, members ...string) error
- func (m *MemStore) Set(key, value string) error
- func (m *MemStore) TTL(key string) (int64, error)
- func (m *MemStore) TableExists(tableName string) (bool, error)
- type Message
- type Options
- type RequestInterceptor
- type Response
- type ResponseInterceptor
- type StoreOption
- type Transaction
- func (t *Transaction) Commit() error
- func (t *Transaction) Exec(query string, args ...interface{}) (sql.Result, error)
- func (t *Transaction) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (t *Transaction) QueryRow(query string, args ...interface{}) *sql.Row
- func (t *Transaction) Rollback() error
- type WailsLog
Constants ¶
This section is empty.
Variables ¶
var ErrKeyNotFound = errors.New("key not found")
ErrKeyNotFound 当在存储中找不到键时返回
Functions ¶
Types ¶
type AIProvider ¶
type AIProvider interface {
// Chat 发送聊天消息
Chat(model string, messages []Message) (string, error)
// ChatStream 发送聊天消息并流式返回结果
ChatStream(model string, messages []Message, callback func(string)) error
// ListModels 获取模型列表
ListModels() ([]string, error)
// Validate 验证连接和配置
Validate() error
}
AIProvider AI提供者接口
type ColumnInfo ¶
type ColumnInfo struct {
Name string `json:"name"`
Type string `json:"type"`
NotNull bool `json:"notNull"`
DefaultValue string `json:"defaultValue"`
PrimaryKey bool `json:"primaryKey"`
}
ColumnInfo 表示列信息
type Config ¶
type Config struct {
BaseURL string
Headers map[string]string
ResponseType string
Method string
HTTPClient *http.Client
}
Config 用于创建 HttpCli 实例的配置
type HttpCli ¶
type HttpCli struct {
// contains filtered or unexported fields
}
HttpCli 是我们的 axios 客户端实例
func (*HttpCli) DownloadFileWithResume ¶
func (c *HttpCli) DownloadFileWithResume(url string, filepath string, progressCallback func(int64, int64)) error
DownloadFileWithResume 支持断点续传的文件下载方法
func (*HttpCli) PostStream ¶
PostStream 发送 POST 请求并返回原始的 http.Response 用于流式处理
func (*HttpCli) UseRequestInterceptor ¶
func (c *HttpCli) UseRequestInterceptor(interceptors ...RequestInterceptor)
func (*HttpCli) UseResponseInterceptor ¶
func (c *HttpCli) UseResponseInterceptor(interceptors ...ResponseInterceptor)
type IStore ¶
type IStore interface {
// KeyValue operations
Set(key, value string) error
Get(key string) (string, error)
Delete(key string) error
List() (map[string]string, error)
// Expiration operations
Expire(key string, milliseconds int64) error
TTL(key string) (int64, error)
// Hash operations (like redis)
HSet(key, field, value string) error
HGet(key, field string) (string, error)
HGetAll(key string) (map[string]string, error)
HMGet(key string, fields ...string) ([]string, error)
HMSet(key string, fieldValue map[string]string) error
HDel(key string, fields ...string) error
HExists(key, field string) (bool, error)
HKeys(key string) ([]string, error)
HLen(key string) (int, error)
// List operations (like redis)
LPush(key string, values ...string) error
RPush(key string, values ...string) error
LPop(key string) (string, error)
RPop(key string) (string, error)
LRange(key string, start, stop int) ([]string, error)
LLen(key string) (int, error)
// Set operations (like redis)
SAdd(key string, members ...string) error
SRem(key string, members ...string) error
SMembers(key string) ([]string, error)
SIsMember(key, member string) (bool, error)
SCard(key string) (int, error)
// SQL operations
Exec(query string, args ...interface{}) (sql.Result, error)
Query(query string, args ...interface{}) (*sql.Rows, error)
QueryRow(query string, args ...interface{}) *sql.Row
// Enhanced SQL operations for table management
CreateTable(tableName string, schema string) error
TableExists(tableName string) (bool, error)
DropTable(tableName string) error
AddColumn(tableName, columnDef string) error
GetTableSchema(tableName string) ([]ColumnInfo, error)
BeginTx() (ITransaction, error)
// Close 关闭存储连接
Close() error
}
IStore 定义存储接口
type ITransaction ¶
type ITransaction interface {
Exec(query string, args ...interface{}) (sql.Result, error)
Query(query string, args ...interface{}) (*sql.Rows, error)
QueryRow(query string, args ...interface{}) *sql.Row
Commit() error
Rollback() error
}
ITransaction 事务接口
type LocalStore ¶
type LocalStore struct {
// contains filtered or unexported fields
}
LocalStore 本地存储
func NewLocalStore ¶
func NewLocalStore(opts ...StoreOption) (*LocalStore, error)
NewLocalStore 创建一个新的本地存储实例
func (*LocalStore) AddColumn ¶
func (l *LocalStore) AddColumn(tableName, columnDef string) error
AddColumn 添加列
func (*LocalStore) CreateTable ¶
func (l *LocalStore) CreateTable(tableName string, schema string) error
CreateTable 创建表
func (*LocalStore) Exec ¶
func (l *LocalStore) Exec(query string, args ...interface{}) (sql.Result, error)
Exec 在本地存储上执行 SQL 语句
func (*LocalStore) Expire ¶
func (l *LocalStore) Expire(key string, milliseconds int64) error
Expire 设置键的过期时间(毫秒)
func (*LocalStore) GetTableSchema ¶
func (l *LocalStore) GetTableSchema(tableName string) ([]ColumnInfo, error)
GetTableSchema 获取表结构信息
func (*LocalStore) HDel ¶
func (l *LocalStore) HDel(key string, fields ...string) error
HDel 删除哈希表key中的一个或多个字段
func (*LocalStore) HExists ¶
func (l *LocalStore) HExists(key, field string) (bool, error)
HExists 检查哈希表key中是否存在字段field
func (*LocalStore) HGet ¶
func (l *LocalStore) HGet(key, field string) (string, error)
HGet 获取哈希表key中字段field的值
func (*LocalStore) HGetAll ¶
func (l *LocalStore) HGetAll(key string) (map[string]string, error)
HGetAll 获取哈希表key中所有的字段和值
func (*LocalStore) HKeys ¶
func (l *LocalStore) HKeys(key string) ([]string, error)
HKeys 获取哈希表key中的所有字段名
func (*LocalStore) HMGet ¶
func (l *LocalStore) HMGet(key string, fields ...string) ([]string, error)
HMGet 获取哈希表key中一个或多个字段的值
func (*LocalStore) HMSet ¶
func (l *LocalStore) HMSet(key string, fieldValue map[string]string) error
HMSet 同时设置哈希表key中一个或多个字段的值
func (*LocalStore) HSet ¶
func (l *LocalStore) HSet(key, field, value string) error
HSet 设置哈希表key中字段field的值
func (*LocalStore) LPush ¶
func (l *LocalStore) LPush(key string, values ...string) error
LPush 将一个或多个值插入到列表key的表头
func (*LocalStore) LRange ¶
func (l *LocalStore) LRange(key string, start, stop int) ([]string, error)
LRange 返回列表key中指定区间内的元素
func (*LocalStore) Query ¶
func (l *LocalStore) Query(query string, args ...interface{}) (*sql.Rows, error)
Query 在本地存储上执行查询
func (*LocalStore) QueryRow ¶
func (l *LocalStore) QueryRow(query string, args ...interface{}) *sql.Row
QueryRow 在本地存储上执行单行查询
func (*LocalStore) RPush ¶
func (l *LocalStore) RPush(key string, values ...string) error
RPush 将一个或多个值插入到列表key的表尾
func (*LocalStore) SAdd ¶
func (l *LocalStore) SAdd(key string, members ...string) error
SAdd 将一个或多个成员加入到集合key中
func (*LocalStore) SCard ¶
func (l *LocalStore) SCard(key string) (int, error)
SCard 返回集合key的基数(集合中元素的数量)
func (*LocalStore) SIsMember ¶
func (l *LocalStore) SIsMember(key, member string) (bool, error)
SIsMember 判断member是否是集合key的成员
func (*LocalStore) SMembers ¶
func (l *LocalStore) SMembers(key string) ([]string, error)
SMembers 返回集合key中的所有成员
func (*LocalStore) SRem ¶
func (l *LocalStore) SRem(key string, members ...string) error
SRem 从集合key中移除一个或多个成员
func (*LocalStore) TableExists ¶
func (l *LocalStore) TableExists(tableName string) (bool, error)
TableExists 检查表是否存在
type LoggerOption ¶
type MemStore ¶
type MemStore struct {
// contains filtered or unexported fields
}
MemStore 内存存储
func NewMemStore ¶
func NewMemStore(opts ...StoreOption) (*MemStore, error)
NewMemStore 创建一个新的内存存储实例
func (*MemStore) CreateTable ¶
CreateTable 创建表
func (*MemStore) GetTableSchema ¶
func (m *MemStore) GetTableSchema(tableName string) ([]ColumnInfo, error)
GetTableSchema 获取表结构信息
type RequestInterceptor ¶
RequestInterceptor 请求拦截器函数类型
type ResponseInterceptor ¶
ResponseInterceptor 响应拦截器函数类型
type StoreOption ¶
type StoreOption struct {
// FilePath 文件保存路径(默认程序运行路径)
FilePath string
// FileName 文件保存名称(默认duola.dat)
FileName string
// Logger 日志记录器
Logger *AppLog
// InitSQL 启动时执行的初始化SQL语句
InitSQL []string
// MaxOpenConns 设置最大打开连接数
MaxOpenConns int
// MaxIdleConns 设置最大空闲连接数
MaxIdleConns int
// OnKeyExpired 当key过期时的回调函数
OnKeyExpired func(key, value string)
}
StoreOption 存储配置选项
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction 事务实现
func (*Transaction) Exec ¶
func (t *Transaction) Exec(query string, args ...interface{}) (sql.Result, error)
Exec 在事务中执行SQL
func (*Transaction) Query ¶
func (t *Transaction) Query(query string, args ...interface{}) (*sql.Rows, error)
Query 在事务中执行查询