Documentation
¶
Index ¶
- Constants
- Variables
- func BuildTableStoreEndpoint(instanceName, regionID, mode string) (string, error)
- func BuildUpdateRowChange(table string, pk *tablestore.PrimaryKey, mut *UpdateMutation, ...) (*tablestore.UpdateRowChange, error)
- func ConvertTablesConfig(cfg *config.TablesConfig) (map[string]*TableConfig, error)
- func DefaultTablesConfigPath() string
- func NewPrimaryKey(entries ...PKEntry) *tablestore.PrimaryKey
- func PrepareRowMapForTableStore(data map[string]interface{}) (map[string]interface{}, error)
- func PrimaryKeyToMap(pk *tablestore.PrimaryKey) map[string]interface{}
- func ResetForTesting()
- func RowMapFromTableStore(raw map[string]interface{}) map[string]interface{}
- func RowToMap(row *tablestore.Row) map[string]interface{}
- func SetDefaultRetryConfig(cfg RetryConfig)
- func SyncTableStoreEndpoint(instanceName string) (string, error)
- func SyncTableStoreEndpointWithRegionId(instanceName, regionID string) (string, error)
- type BatchGetRowItem
- type BatchWriteAction
- type Client
- type ColumnVersionDelete
- type GetRangeOptions
- type GetRangePage
- type GetRowOptions
- type Operator
- type Option
- type PKEntry
- type PrimaryKey
- type RetryConfig
- type Row
- type RowCondition
- type SimpleTableOperator
- type TableConfig
- type UpdateData
- type UpdateMutation
Constants ¶
const ( // EndpointModeDevelopment 表示开发模式:使用公网 endpoint。 EndpointModeDevelopment = otscore.EndpointModeDevelopment // EndpointModeProduction 表示生产模式:使用 VPC endpoint。 EndpointModeProduction = otscore.EndpointModeProduction // FORWARD 表示正向扫描,BACKWARD 表示反向扫描 FORWARD = tablestore.FORWARD BACKWARD = tablestore.BACKWARD // INF_MIN 表示无穷小,INF_MAX 表示无穷大 INF_MIN = tablestore.MIN INF_MAX = tablestore.MAX // RT_NONE 表示不返回行数据体 RT_NONE = tablestore.ReturnType_RT_NONE // RT_PK 表示返回主键 RT_PK = tablestore.ReturnType_RT_PK // RT_ALT 表示返回修改列 RT_ALT = tablestore.ReturnType_RT_AFTER_MODIFY )
Variables ¶
var ( // EXPECT_EXIST 表示期望存在 EXPECT_EXIST = &tablestore.RowCondition{ RowExistenceExpectation: tablestore.RowExistenceExpectation_EXPECT_EXIST, } // EXPECT_NOT_EXIST 表示期望不存在 EXPECT_NOT_EXIST = &tablestore.RowCondition{ RowExistenceExpectation: tablestore.RowExistenceExpectation_EXPECT_NOT_EXIST, } // IGNORE 表示忽略 IGNORE = &tablestore.RowCondition{ RowExistenceExpectation: tablestore.RowExistenceExpectation_IGNORE, } )
Functions ¶
func BuildTableStoreEndpoint ¶
BuildTableStoreEndpoint 根据实例名、地域 ID(与 YAML regionId 一致)与运行模式拼接 TableStore endpoint。 供同步工具等场景与 SDK 内部共用,规则与 New 系列一致。
func BuildUpdateRowChange ¶
func BuildUpdateRowChange(table string, pk *tablestore.PrimaryKey, mut *UpdateMutation, cond *tablestore.RowCondition) (*tablestore.UpdateRowChange, error)
BuildUpdateRowChange 由 UpdateMutation 生成 UpdateRowChange,可与 BatchWriteRowChanges 组合使用。
func ConvertTablesConfig ¶
func ConvertTablesConfig(cfg *config.TablesConfig) (map[string]*TableConfig, error)
ConvertTablesConfig 将 config 包中的 YAML 结构转换为运行时表配置。 转换过程中会校验字段类型是否合法,确保错误尽早暴露在初始化阶段。
func DefaultTablesConfigPath ¶
func DefaultTablesConfigPath() string
DefaultTablesConfigPath 返回默认配置路径。 解析顺序: 1. 优先读取环境变量 SIMPLEOTSGO_TABLES_PATH; 2. 未设置时回落到当前工作目录下的 config/tables.yaml。
func NewPrimaryKey ¶
func NewPrimaryKey(entries ...PKEntry) *tablestore.PrimaryKey
NewPrimaryKey 按表定义顺序构造 *tablestore.PrimaryKey。
func PrepareRowMapForTableStore ¶
PrepareRowMapForTableStore 写入前编码 *_json 列(与 PutRow 行为一致,供直连底层 SDK 时使用)。
func PrimaryKeyToMap ¶
func PrimaryKeyToMap(pk *tablestore.PrimaryKey) map[string]interface{}
PrimaryKeyToMap 将 PrimaryKey 转为 map(无序;续扫分页请使用 *tablestore.PrimaryKey)。
func ResetForTesting ¶
func ResetForTesting()
ResetForTesting 重置所有全局缓存与初始化状态,仅供测试使用。 生产代码不应调用此函数;它使同一进程内的不同测试用例可以独立初始化。
func RowMapFromTableStore ¶
RowMapFromTableStore 将含 *_json 字符串列的 map 解析为嵌套 map/slice(与 GetRow 系列行为一致)。
func RowToMap ¶
func RowToMap(row *tablestore.Row) map[string]interface{}
RowToMap 将 *tablestore.Row 转为 map,并自动解析 *_json 列为对象/数组。
func SetDefaultRetryConfig ¶
func SetDefaultRetryConfig(cfg RetryConfig)
SetDefaultRetryConfig 设置全局重试配置。
func SyncTableStoreEndpoint ¶
SyncTableStoreEndpoint 解析同步工具连接用的 endpoint。 若已设置 TABLESTORE_ENDPOINT,则全实例共用该地址(多实例 YAML 时请慎用); 否则须由调用方传入从 tables.yaml 解析出的 regionId,并结合运行模式拼接。
func SyncTableStoreEndpointWithRegionId ¶
SyncTableStoreEndpointWithRegionId 解析同步工具连接 endpoint;regionID 须来自 tables.yaml(同实例下各表 regionId 应一致)。 优先级:TABLESTORE_ENDPOINT > 传入 regionID(环境变量不再作为地域来源)。
Types ¶
type BatchGetRowItem ¶
type BatchGetRowItem = otscore.BatchGetRowItem
type BatchWriteAction ¶
type BatchWriteAction = otscore.BatchWriteAction
type ColumnVersionDelete ¶
type ColumnVersionDelete = otscore.ColumnVersionDelete
type GetRangeOptions ¶
type GetRangeOptions = otscore.GetRangeOptions
type GetRangePage ¶
type GetRangePage = otscore.GetRangePage
type GetRowOptions ¶
type GetRowOptions = otscore.GetRowOptions
GetRowOptions、BatchGetRowItem、GetRangeOptions、GetRangePage(可选的已解码分页视图)等为行级读写相关类型。
type Operator ¶
type Operator struct {
// contains filtered or unexported fields
}
Operator 是面向业务层的简化入口。 设计目标是只要求 AccessKey/SecretKey,表结构与实例信息由 tables.yaml 决定。
func New ¶
New 创建最简 SDK 操作入口。 1. 自动加载 tables.yaml(按默认或 SIMPLEOTSGO_TABLES_PATH 解析的绝对路径;与上次已成功加载的路径相同时跳过重复读,否则重新加载); 2. 自动读取 TABLESTORE_ENDPOINT(可选;未设置时依赖各表 regionId 拼接 endpoint); 3. 返回可按表名获取操作器的 Operator。
func NewWithConfig ¶
NewWithConfig 创建可完全自定义初始化参数的入口。 tablesPath 为空时会走 DefaultTablesConfigPath;不为空时使用传入路径。 与当前进程已成功注册的 YAML 绝对路径不一致时会重新读取并替换全局表配置(同进程多文件场景)。
func NewWithEndpoint ¶
NewWithEndpoint 在代码中显式指定 endpoint。 当调用方不想依赖环境变量时,建议使用该函数。
type PrimaryKey ¶
type PrimaryKey = tablestore.PrimaryKey
type Row ¶
type Row = tablestore.Row
type RowCondition ¶
type RowCondition = tablestore.RowCondition
type SimpleTableOperator ¶
type SimpleTableOperator = otscore.SimpleTableOperator
SimpleTableOperator 对外暴露操作器类型,保持与核心实现一致。
func Table ¶
func Table(tableName string) (*SimpleTableOperator, error)
Table 提供“零实例化”快捷入口:用户无需显式创建 Operator,直接按表名获取操作器。 凭证来源:优先 TABLESTORE_ACCESS_KEY_ID/TABLESTORE_ACCESS_KEY_SECRET,回退 TABLESTORE_ACCESS_KEY/TABLESTORE_SECRET_KEY。
type UpdateData ¶
type UpdateData = otscore.UpdateData
UpdateData 为 UpdateRow 的入参结构体(RowData / DeleteColumns / IncrementColumns),与 internal/otscore 定义一致。
type UpdateMutation ¶
type UpdateMutation = otscore.UpdateMutation