trule

package
v0.0.0-...-2e4edee Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TRANSACTION_SIGNAL_CHANNEL_LEN = 2   // 事务信号channel的大小
	TRANSACTION_CLEAN_TIME_OUT     = 600 // 事务的超时时间,超时这段时间后就会被清理,单位秒

	SPOT_CACHE_SIGNAL_CHANNEL_LEN = 2   // spot缓存信号channel的大小
	SPOT_CACHE_CLEAN_CYCLE        = 200 // spot缓存的清理周期,每几次有效的角色请求之后进行
	SPOT_CACHE_CLEAN_TIME_OUT     = 600 // 超时的spot缓存时间,超时这段时间后就会被清理,单位秒
)
View Source
const (
	// 运行状态
	TRULE_RUN_NO       = iota // 未指定
	TRULE_RUN_RUNNING         // 正在运行
	TRULE_RUN_PAUSEING        // 正在暂停
	TRULE_RUN_PAUSED          // 已经暂停
)
View Source
const (
	// 事务占用角色的锁模式
	TRAN_LOCK_MODE_NO = iota
	// 读
	TRAN_LOCK_MODE_READ
	// 写
	TRAN_LOCK_MODE_WRITE
)
View Source
const (
	// 事务超时监测时间,单位秒
	TRAN_TIME_OUT_CHECK = 30
	// 事务超时时间,单位为秒
	TRAN_TIME_OUT = 120
	// 最多事务数
	TRAN_MAX_COUNT = 1000
)
View Source
const (
	// 事务的提交请求
	TRANSACTION_ASK_NO = iota
	// 请求建立
	TRANSACTION_ASK_BEGIN
	// 请求执行
	TRANSACTION_ASK_COMMIT
	// 请求回滚
	TRANSACTION_ASK_ROLLBACK
	// 请求消灭
	TRANSACTION_ASK_DELETE
	// 请求清理
	TRANSACTION_ASK_CLEAN
)
View Source
const (
	// spot缓存的请求
	SPOT_CACHE_ASK_NO = iota
	// 请求获取
	SPOT_CACHE_ASK_GET
	// 请求写入
	SPOT_CACHE_ASK_WRITE
	// 请求完成
	SPOT_CACHE_ASK_STORE
	// 请求重置
	SPOT_CACHE_ASK_RESET
	// 请求删除
	SPOT_CACHE_ASK_DELETE
	// 请求释放
	SPOT_CACHE_ASK_RELEASE
	// 请求清理
	SPOT_CACHE_ASK_CLEAN
)
View Source
const (
	// spot请求的返回
	SPOT_CACHE_RETURN_HANDLE_NO = iota
	// 返回OK
	SPOT_CACHE_RETURN_HANDLE_OK
	// 返回错误
	SPOT_CACHE_RETURN_HANDLE_ERROR
)
View Source
const (
	// 事务提交或回滚后得到的从TRule的返回状态
	TRAN_RETURN_HANDLE_NO = iota
	// 返回OK
	TRAN_RETURN_HANDLE_OK
	// 返回错误
	TRAN_RETURN_HANDLE_ERROR
)
View Source
const (
	// spot被删除——没有
	TRAN_SPOT_BE_DELETE_NO = iota
	// spot被标记删除
	TRAN_SPOT_BE_DELETE_YES
	// spot被真正删除掉了
	TRAN_SPOT_BE_DELETE_COMMIT
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BbodyMarshaler

type BbodyMarshaler interface {
	BbodyMarshel(name string, data interface{}) (b []byte, err error)
	BbodyUnmarshaler(name string, b []byte, data interface{}) (err error)
}

type TRule

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

事务统治者

func NewTRule

func NewTRule(local_store *hardstorage.HardStorage, log *ilogs.Logs) (t *TRule)

func (*TRule) Begin

func (t *TRule) Begin() (tran *Transaction, err error)

Begin a transaction

func (*TRule) Start

func (t *TRule) Start() (err error)

func (*TRule) Stop

func (t *TRule) Stop()

type Transaction

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

事务

func (*Transaction) Commit

func (t *Transaction) Commit() (err error)

func (*Transaction) CreateContext

func (t *Transaction) CreateContext(area, id, contextname string) (err error)

func (*Transaction) DeleteChild

func (t *Transaction) DeleteChild(area, id, child string) (err error)

func (*Transaction) DeleteContextBind

func (t *Transaction) DeleteContextBind(area, id, contextname string, upordown spots.ContextUpDown, bindspot string) (err error)

func (*Transaction) DeleteFriend

func (t *Transaction) DeleteFriend(area, id, friend string) (err error)

func (*Transaction) DeleteSpot

func (t *Transaction) DeleteSpot(area, id string) (err error)

Delete a Spot

func (*Transaction) DropContext

func (t *Transaction) DropContext(area, id, contextname string) (err error)

func (*Transaction) ExistChild

func (t *Transaction) ExistChild(area, id, child string) (have bool, err error)

func (*Transaction) ExistContext

func (t *Transaction) ExistContext(area, id, contextname string) (have bool, err error)

func (*Transaction) ExistSpot

func (t *Transaction) ExistSpot(area, id string) (exist bool, err error)

If the Spot exist.

func (*Transaction) ReadChildren

func (t *Transaction) ReadChildren(area, id string) (children []string, err error)

func (*Transaction) ReadContext

func (t *Transaction) ReadContext(area, id, contextname string) (context spots.Context, have bool, err error)

func (*Transaction) ReadContextComplexStatus

func (t *Transaction) ReadContextComplexStatus(area, id, contextname string, upordown spots.ContextUpDown, bindspotid string, bindbit int) (value complex128, have bool, err error)

func (*Transaction) ReadContextFloatStatus

func (t *Transaction) ReadContextFloatStatus(area, id, contextname string, upordown spots.ContextUpDown, bindspotid string, bindbit int) (value float64, have bool, err error)

func (*Transaction) ReadContextIntStatus

func (t *Transaction) ReadContextIntStatus(area, id, contextname string, upordown spots.ContextUpDown, bindspotid string, bindbit int) (value int64, have bool, err error)

func (*Transaction) ReadContextStringStatus

func (t *Transaction) ReadContextStringStatus(area, id, contextname string, upordown spots.ContextUpDown, bindspotid string, bindbit int) (value string, have bool, err error)

func (*Transaction) ReadContexts

func (t *Transaction) ReadContexts(area, id string) (contexts map[string]spots.Context, err error)

func (*Transaction) ReadContextsName

func (t *Transaction) ReadContextsName(area, id string) (names []string, err error)

func (*Transaction) ReadData

func (t *Transaction) ReadData(area, id, name string, data interface{}) (err error)

func (*Transaction) ReadDataBytes

func (t *Transaction) ReadDataBytes(area, id string, name string) (data []byte, err error)

func (*Transaction) ReadDataFromBbody

func (t *Transaction) ReadDataFromBbody(area, id string, prototype BbodyMarshaler, name string, data interface{}) (err error)

func (*Transaction) ReadFather

func (t *Transaction) ReadFather(area, id string) (father string, err error)

func (*Transaction) ReadFriendComplexStatus

func (t *Transaction) ReadFriendComplexStatus(area, id, friend string, bindbit int) (value complex128, have bool, err error)

func (*Transaction) ReadFriendFloatStatus

func (t *Transaction) ReadFriendFloatStatus(area, id, friend string, bindbit int) (value float64, have bool, err error)

func (*Transaction) ReadFriendIntStatus

func (t *Transaction) ReadFriendIntStatus(area, id, friend string, bindbit int) (value int64, have bool, err error)

func (*Transaction) ReadFriendStringStatus

func (t *Transaction) ReadFriendStringStatus(area, id, friend string, bindbit int) (value string, have bool, err error)

func (*Transaction) ReadFriends

func (t *Transaction) ReadFriends(area, id string) (friends map[string]spots.Status, err error)

func (*Transaction) ReadSpot

func (t *Transaction) ReadSpot(area, id string) (spot *spots.Spots, err error)

Read a Spot

func (*Transaction) ReadSpotWithBody

func (t *Transaction) ReadSpotWithBody(area, id string, body spots.DataBodyer) (spot *spots.Spots, err error)

func (*Transaction) ResetChildren

func (t *Transaction) ResetChildren(area, id string) (err error)

func (*Transaction) ResetContexts

func (t *Transaction) ResetContexts(area, id string) (err error)

func (*Transaction) ResetFather

func (t *Transaction) ResetFather(area, id string) (err error)

func (*Transaction) ResetFriends

func (t *Transaction) ResetFriends(area, id string) (err error)

func (*Transaction) Rollback

func (t *Transaction) Rollback() (err error)

func (*Transaction) StoreSpot

func (t *Transaction) StoreSpot(area string, spot *spots.Spots) (err error)

Store Spot

func (*Transaction) WriteChild

func (t *Transaction) WriteChild(area, id, child string) (err error)

func (*Transaction) WriteChildren

func (t *Transaction) WriteChildren(area, id string, children []string) (err error)

func (*Transaction) WriteContext

func (t *Transaction) WriteContext(area, id, contextname string, context spots.Context) (err error)

func (*Transaction) WriteContextComplexStatus

func (t *Transaction) WriteContextComplexStatus(area, id, contextname string, upordown spots.ContextUpDown, bindspotid string, bindbit int, value complex128) (err error)

func (*Transaction) WriteContextFloatStatus

func (t *Transaction) WriteContextFloatStatus(area, id, contextname string, upordown spots.ContextUpDown, bindspotid string, bindbit int, value float64) (err error)

func (*Transaction) WriteContextIntStatus

func (t *Transaction) WriteContextIntStatus(area, id, contextname string, upordown spots.ContextUpDown, bindspotid string, bindbit int, value int64) (err error)

func (*Transaction) WriteContextStringStatus

func (t *Transaction) WriteContextStringStatus(area, id, contextname string, upordown spots.ContextUpDown, bindspotid string, bindbit int, value string) (err error)

func (*Transaction) WriteContexts

func (t *Transaction) WriteContexts(area, id string, contexts map[string]spots.Context) (err error)

func (*Transaction) WriteData

func (t *Transaction) WriteData(area, id, name string, data interface{}) (err error)

func (*Transaction) WriteDataBytes

func (t *Transaction) WriteDataBytes(area, id string, name string, data []byte) (err error)

func (*Transaction) WriteDataToBbody

func (t *Transaction) WriteDataToBbody(area, id string, prototype BbodyMarshaler, name string, data interface{}) (err error)

func (*Transaction) WriteFather

func (t *Transaction) WriteFather(area, id, father string) (err error)

func (*Transaction) WriteFriendComplexStatus

func (t *Transaction) WriteFriendComplexStatus(area, id, friend string, bindbit int, value complex128) (err error)

func (*Transaction) WriteFriendFloatStatus

func (t *Transaction) WriteFriendFloatStatus(area, id, friend string, bindbit int, value float64) (err error)

func (*Transaction) WriteFriendIntStatus

func (t *Transaction) WriteFriendIntStatus(area, id, friend string, bindbit int, value int64) (err error)

func (*Transaction) WriteFriendStringStatus

func (t *Transaction) WriteFriendStringStatus(area, id, friend string, bindbit int, value string) (err error)

func (*Transaction) WriteFriends

func (t *Transaction) WriteFriends(area, id string, friends map[string]spots.Status) (err error)

Jump to

Keyboard shortcuts

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