Documentation
¶
Index ¶
- Constants
- Variables
- func Audit(op string, hash string, coll string, timestamp string, ...) error
- func HistoryRecord(op string, hash string, version int, coll string, timestamp string, ...) error
- func InsertInfo(hash string, coll string, pubkey string, timestamp string) (int, error)
- func OpRecord(op string, version int, hash string, coll string, timestamp string, ...) error
- func UpdateInfo(hash string) (int, error)
- type AuditModel
- type CollectionCommand
- type CollectionFeature
- type DeleteCommand
- type DocInfoDoc
- type GeneralCommand
- type HistoryDoc
- type IndexCommand
- type InsertCommand
- type InstructionExecutor
- func (t *InstructionExecutor) Execute(command GeneralCommand) (err error)
- func (t *InstructionExecutor) InitCollection(ctx context.Context, collName string) (err error)
- func (t *InstructionExecutor) InitDefault()
- func (t *InstructionExecutor) Name() string
- func (t *InstructionExecutor) PermissionVerify(op string, collection string, publickey string) bool
- func (t *InstructionExecutor) Start()
- func (t *InstructionExecutor) Stop()
- func (t *InstructionExecutor) UpdateCollectionFeatures(collection string, feature map[string]interface{}) (bool, *CollectionCommand)
- type InstructionExecutorConfig
- type MasterDataDoc
- type MasterDocInfoDoc
- type MasterHistoryDoc
- type MasterOpRecordDoc
- type OpDoc
- type OpRecordDoc
- type UpdateCommand
Constants ¶
View Source
const ( CreateCollection string = "create_collection" UpdateCollection string = "update_collection" Insert string = "insert" Update string = "update" Delete string = "delete" CreateIndex string = "hint_create_index" DropIndex string = "hint_drop_index" CommandCollection string = "_op" MasterCollection string = "_master" )
Variables ¶
View Source
var ( DataType = "data" // for actual data storage HistoryType = "history" // data history versions OpRecordType = "oprecord" // DocInfoType = "info" // document info )
View Source
var InitCollections = []string{DataType, HistoryType, OpRecordType, DocInfoType}
View Source
var NamePattern = map[string]string{ DataType: "%s_" + DataType, HistoryType: "%s_" + HistoryType, OpRecordType: "%s_" + OpRecordType, DocInfoType: "%s_" + DocInfoType, }
Functions ¶
func HistoryRecord ¶
func InsertInfo ¶
func UpdateInfo ¶
Types ¶
type AuditModel ¶
type AuditModel struct {
OpHash string `json:"_id"` //数据的hash
//Collection string `json:"collection"` //操作的数据表
Operation string `json:"operation"`
Timestamp string `json:"timestamp"`
Data map[string]interface{} `json:"data"` //操作记录
PublicKey string `json:"public_key"` //公钥
Signature string `json:"signature"` //签名
}
Audit table. merged to oprecord
type CollectionCommand ¶
type CollectionCommand struct {
//OpHash string `json:"op_hash"` //产生数据的hash作为主键
Op string `json:"op"`
Collection string `json:"collection"` //要操作的数据表
Feature CollectionFeature `json:"feature"`
PublicKey string `json:"public_key"` //公钥
}
type CollectionFeature ¶
type CollectionFeature struct {
AllowUpdate bool `json:"allow_update"`
AllowDelete bool `json:"allow_delete"`
Cooperate bool `json:"cooperate"`
AllowInsertMembers []string `json:"allow_insert_members"`
AllowUpdateMembers []string `json:"allow_update_members"`
AllowDeleteMembers []string `json:"allow_delete_members"`
}
type DeleteCommand ¶
type DocInfoDoc ¶
type DocInfoDoc struct {
DocId string `json:"doc_id"` // 文档Id
Version int `json:"version"`
//Collection string `json:"collection"` //操作的数据表
CreatedAt int64 `json:"created_at"` // timestamp ms
CreatedBy string `json:"created_by"`
ModifiedAt int64 `json:"modified_at"` // timestamp ms
ModifiedBy string `json:"modified_by"`
}
info table
type GeneralCommand ¶
type HistoryDoc ¶
type HistoryDoc struct {
DocId string `json:"doc_id"` // 文档Id
Version int `json:"version"`
//Collection string `json:"collection"` //操作的数据表
Timestamp string `json:"timestamp"`
Data map[string]interface{} `json:"history"` //历史版本
PublicKey string `json:"public_key"` //公钥
Signature string `json:"signature"` //签名
}
history table。
func GetHistoryRecord ¶
func GetHistoryRecord(hash string, coll string) []HistoryDoc
type IndexCommand ¶
type InsertCommand ¶
type InstructionExecutor ¶
type InstructionExecutor struct {
Config InstructionExecutorConfig
// contains filtered or unexported fields
}
func (*InstructionExecutor) Execute ¶
func (t *InstructionExecutor) Execute(command GeneralCommand) (err error)
func (*InstructionExecutor) InitCollection ¶
func (t *InstructionExecutor) InitCollection(ctx context.Context, collName string) (err error)
InitCollection setup all necessary collections to support business
func (*InstructionExecutor) InitDefault ¶
func (t *InstructionExecutor) InitDefault()
func (*InstructionExecutor) Name ¶
func (t *InstructionExecutor) Name() string
func (*InstructionExecutor) PermissionVerify ¶
func (t *InstructionExecutor) PermissionVerify(op string, collection string, publickey string) bool
TODO: do not enable permission verification unless you can load all collections at start up
func (*InstructionExecutor) Start ¶
func (t *InstructionExecutor) Start()
func (*InstructionExecutor) Stop ¶
func (t *InstructionExecutor) Stop()
func (*InstructionExecutor) UpdateCollectionFeatures ¶
func (t *InstructionExecutor) UpdateCollectionFeatures(collection string, feature map[string]interface{}) (bool, *CollectionCommand)
更新Coll
type MasterDataDoc ¶
type MasterDataDoc struct {
OpHash string `json:"op_hash"`
Collection string `json:"collection"` //操作的数据表
Feature CollectionFeature `json:"feature"`
PublicKey string `json:"public_key"` //公钥
Signature string `json:"signature"` //签名
Timestamp int64 `json:"timestamp"`
}
current data
type MasterDocInfoDoc ¶
type MasterDocInfoDoc struct {
Collection string `json:"collection"` //操作的数据表
Version int `json:"version"`
CreatedAt int64 `json:"created_at"` // timestamp ms
CreatedBy string `json:"created_by"`
ModifiedAt int64 `json:"modified_at"` // timestamp ms
ModifiedBy string `json:"modified_by"`
}
info table
type MasterHistoryDoc ¶
type MasterHistoryDoc struct {
OpHash string `json:"op_hash"`
Version int `json:"version"`
TxHash string `json:"tx_hash"`
Collection string `json:"collection"` //操作的数据表
Feature CollectionFeature `json:"feature"`
PublicKey string `json:"public_key"` //公钥
Signature string `json:"signature"` //签名
Timestamp int64 `json:"timestamp"`
}
history data
type MasterOpRecordDoc ¶
type MasterOpRecordDoc struct {
OpHash string `json:"op_hash"`
TxHash string `json:"tx_hash"`
Collection string `json:"collection"` //操作的数据表
Feature CollectionFeature `json:"feature"`
PublicKey string `json:"public_key"` //公钥
Signature string `json:"signature"` //签名
Timestamp int64 `json:"timestamp"`
}
operation
type OpDoc ¶
type OpDoc struct {
Order int32 `json:"oder"`
IsExecuted bool `json:"is_executed"`
TxHash string `json:"tx_hash"`
OpHash string `json:"op_hash"`
OpStr string `json:"op_str"`
Signature string `json:"signature"`
PublicKey string `json:"public_key"`
}
OpDoc is the task queue filled by chain sync. update OpDoc once the OpDoc is executed.
type OpRecordDoc ¶
type OpRecordDoc struct {
DocId string `json:"doc_id"` // 文档Id
OpHash string `json:"op_hash"` //数据的hash
Version int `json:"version"`
//Collection string `json:"collection"` //操作的数据表
Operation string `json:"operation"`
Timestamp string `json:"timestamp"`
Data map[string]interface{} `json:"data"` //操作记录
PublicKey string `json:"public_key"` //公钥
Signature string `json:"signature"` //签名
}
oprecord table. One for each collection
func GetOpRecordsById ¶
func GetOpRecordsById(hash string, coll string) []OpRecordDoc
type UpdateCommand ¶
Click to show internal directories.
Click to hide internal directories.