Documentation
¶
Index ¶
- Constants
- func InitOtsClient()
- type Config
- type Datastore
- type DatastoreFactory
- type DatastoreType
- type OtsStore
- func (o *OtsStore) Close() error
- func (o *OtsStore) Delete(key string) error
- func (o *OtsStore) Get(key string, columns []string) (map[string]interface{}, error)
- func (o *OtsStore) ListAll(columns []string) (map[string]map[string]interface{}, error)
- func (o *OtsStore) Put(key string, datas map[string]interface{}) error
- func (o *OtsStore) Update(key string, datas map[string]interface{}) error
- type SQLiteDatastore
- func (ds *SQLiteDatastore) Close() error
- func (ds *SQLiteDatastore) Delete(key string) error
- func (ds *SQLiteDatastore) Get(key string, columns []string) (map[string]interface{}, error)
- func (ds *SQLiteDatastore) ListAll(columns []string) (map[string]map[string]interface{}, error)
- func (ds *SQLiteDatastore) Put(key string, values map[string]interface{}) error
- func (ds *SQLiteDatastore) Update(key string, values map[string]interface{}) error
Constants ¶
View Source
const ( KModelServiceTableName = "function" KModelServiceKey = "PRIMARY_KEY" KModelServiceFunctionName = "FUNCTION" KModelServiceSdModel = "SD_MODEL" KModelServiceEndPoint = "END_POINT" KModelServerImage = "IMAGE" KModelServiceMessage = "MESSAGE" KModelServiceCreateTime = "FUNC_CREATE_TIME" KModelServiceLastModifyTime = "FUNC_LAST_MODIFY_TIME" )
function table
View Source
const ( KModelTableName = "models" KModelType = "MODEL_TYPE" KModelName = "MODEL_NAME" KModelOssPath = "MODEL_OSS_PATH" KModelEtag = "MODEL_ETAG" KModelStatus = "MODEL_STATUS" KModelLocalPath = "MODEL_LOCAL_PATH" KModelCreateTime = "MODEL_REGISTERED" KModelModifyTime = "MODEL_MODIFY" )
models table
View Source
const ( KTaskTableName = "tasks" KTaskIdColumnName = "TASK_ID" KTaskUser = "TASK_USER" KTaskProgressColumnName = "TASK_PROGRESS" KTaskInfo = "TASK_INFO" KTaskImage = "TASK_IMAGE" KTaskCode = "TASK_CODE" KTaskCancel = "TASK_CANCEL" KTaskParams = "TASK_PARAMS" KTaskStatus = "TASK_STATUS" KTaskCreateTime = "TASK_CREATE_TIME" KTaskModifyTime = "TASK_MODIFY_TIME" )
tasks table
View Source
const ( KUserTableName = "users" KUserName = "USER_NAME" KUserPassword = "USER_PASSWORD" KUserSession = "USER_SESSION" KUserSessionValidTime = "USER_SESSION_VALID" KUserConfig = "USER_CONFIG" KUserConfigVer = "USER_CONFIG_VERSION" KUserCreateTime = "USER_CREATE_TIME" KUserModifyTime = "USER_MODIFY_TIME" )
user table
View Source
const ( KConfigTableName = "config" KConfigKey = "CONFIG_KEY" KConfigVal = "CONFIG_VAL" KConfigMd5 = "CONFIG_MD5" KConfigVer = "CONFIG_VERSION" KConfigCreateTime = "CONFIG_CREATE_TIME" KConfigModifyTime = "CONFIG_MODIFY_TIME" )
config
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Type DatastoreType // the datastore type
DBName string // the database name
TableName string
ColumnConfig map[string]string // map of column name to column type
PrimaryKeyColumnName string
TimeToAlive int
MaxVersion int
}
func NewOtsConfig ¶
func NewSQLiteConfig ¶
type Datastore ¶
type Datastore interface {
// Put inserts or updates the column values in the datastore.
// It takes a key and a map of column names to values, and returns an error if the operation failed.
Put(key string, values map[string]interface{}) error
// Update the partial column values.
// It tasks a key and a map of column names to values, and returns an error if the operation failed.
Update(key string, values map[string]interface{}) error
// Get retrieves the column values from the datastore.
// It takes a key and a slice of column names, and returns a map of column names to values,
// along with an error if the operation failed.
// If the key does not exist, the returned map and error are both nil.
Get(key string, columns []string) (map[string]interface{}, error)
// Delete removes a value from the datastore.
// It takes a key, and returns an error if the operation failed.
// Note: delete a non-existent key will not return an error.
Delete(key string) error
// ListAll read all data from the datastore.
// It takes a list of column name, and return a nested map, which means map[primaryKey]map[columanName]columanValue.
// Note: since it reads all data and store them in memory, so do not call this function on a large datastore.
ListAll(columns []string) (map[string]map[string]interface{}, error)
// Close close the datastore.
Close() error
}
type DatastoreFactory ¶
type DatastoreFactory struct{}
func (*DatastoreFactory) NewTable ¶
func (f *DatastoreFactory) NewTable(dbType DatastoreType, tableName string) Datastore
type DatastoreType ¶
type DatastoreType string
const ( SQLite DatastoreType = "sqlite" MySQL DatastoreType = "mysql" TableStore DatastoreType = "tableStore" )
type OtsStore ¶
type OtsStore struct {
// contains filtered or unexported fields
}
func NewOtsDatastore ¶
type SQLiteDatastore ¶
type SQLiteDatastore struct {
// contains filtered or unexported fields
}
func NewSQLiteDatastore ¶
func NewSQLiteDatastore(config *Config) *SQLiteDatastore
func (*SQLiteDatastore) Close ¶
func (ds *SQLiteDatastore) Close() error
func (*SQLiteDatastore) Delete ¶
func (ds *SQLiteDatastore) Delete(key string) error
func (*SQLiteDatastore) Get ¶
func (ds *SQLiteDatastore) Get(key string, columns []string) (map[string]interface{}, error)
func (*SQLiteDatastore) ListAll ¶
func (ds *SQLiteDatastore) ListAll(columns []string) (map[string]map[string]interface{}, error)
Click to show internal directories.
Click to hide internal directories.