Documentation ¶
Overview ¶
drule2的远程操作者
Index ¶
- Constants
- type DRuleError
- type DRuleOperateMode
- type DRuleReturnStatus
- type OTransaction
- func (o *OTransaction) Commit() (errs DRuleError)
- func (o *OTransaction) CreateContext(areaid, roleid, contextname string) (errs DRuleError)
- func (o *OTransaction) DeleteChild(areaid, roleid, childid string) (errs DRuleError)
- func (o *OTransaction) DeleteContextBind(areaid, roleid, contextname string, upordown roles.ContextUpDown, ...) (errs DRuleError)
- func (o *OTransaction) DeleteFriend(areaid, roleid, friendid string) (errs DRuleError)
- func (o *OTransaction) DeleteRole(areaid, roleid string) (errs DRuleError)
- func (o *OTransaction) DropContext(areaid, roleid, contextname string) (errs DRuleError)
- func (o *OTransaction) ExistChild(areaid, roleid, childid string) (have bool, errs DRuleError)
- func (o *OTransaction) ExistContext(areaid, roleid, contextname string) (have bool, errs DRuleError)
- func (o *OTransaction) ExistRole(area, id string) (have bool, errs DRuleError)
- func (o *OTransaction) LockRole(areaid string, roleids ...string) (errs DRuleError)
- func (o *OTransaction) ReadChildren(areaid, roleid string) (children []string, errs DRuleError)
- func (o *OTransaction) ReadContext(areaid, roleid, contextname string) (context roles.Context, have bool, errs DRuleError)
- func (o *OTransaction) ReadContextSameBind(areaid, roleid, contextname string, upordown roles.ContextUpDown, bind int64) (rolesid []string, have bool, errs DRuleError)
- func (o *OTransaction) ReadContextStatus(areaid, roleid, contextname string, upordown roles.ContextUpDown, ...) (have bool, errs DRuleError)
- func (o *OTransaction) ReadContexts(areaid, roleid string) (contexts map[string]roles.Context, errs DRuleError)
- func (o *OTransaction) ReadContextsName(areaid, roleid string) (names []string, errs DRuleError)
- func (o *OTransaction) ReadData(areaid, roleid, name string, data interface{}) (errs DRuleError)
- func (o *OTransaction) ReadDataToByte(areaid, roleid, name string) (data_b []byte, errs DRuleError)
- func (o *OTransaction) ReadFather(areaid, roleid string) (fatherid string, errs DRuleError)
- func (o *OTransaction) ReadFriendStatus(areaid, roleid, friendid string, bindbit int, value interface{}) (have bool, errs DRuleError)
- func (o *OTransaction) ReadFriends(areaid, roleid string) (firends map[string]roles.Status, errs DRuleError)
- func (o *OTransaction) ReadRole(area, id string, role roles.Roleer) (errs DRuleError)
- func (o *OTransaction) ReadRoleToMiddleData(area, id string) (md roles.RoleMiddleData, errs DRuleError)
- func (o *OTransaction) ResetChildren(areaid, roleid string) (errs DRuleError)
- func (o *OTransaction) ResetContexts(areaid, roleid string) (errs DRuleError)
- func (o *OTransaction) ResetFather(areaid, roleid string) (errs DRuleError)
- func (o *OTransaction) ResetFriends(areaid, roleid string) (errs DRuleError)
- func (o *OTransaction) Rollback() (errs DRuleError)
- func (o *OTransaction) StoreRole(area string, role roles.Roleer) (errs DRuleError)
- func (o *OTransaction) StoreRoleFromMiddleData(area string, rolemid roles.RoleMiddleData) (errs DRuleError)
- func (o *OTransaction) TransactionId() (id string)
- func (o *OTransaction) WriteChild(areaid, roleid, childid string) (errs DRuleError)
- func (o *OTransaction) WriteChildren(areaid, roleid string, children []string) (errs DRuleError)
- func (o *OTransaction) WriteContext(areaid, roleid, contextname string, context roles.Context) (errs DRuleError)
- func (o *OTransaction) WriteContextStatus(areaid, roleid, contextname string, upordown roles.ContextUpDown, ...) (errs DRuleError)
- func (o *OTransaction) WriteContexts(areaid, roleid string, contexts map[string]roles.Context) (errs DRuleError)
- func (o *OTransaction) WriteData(areaid, roleid, name string, data interface{}) (errs DRuleError)
- func (o *OTransaction) WriteDataFromByte(areaid, roleid, name string, data_b []byte) (errs DRuleError)
- func (o *OTransaction) WriteFather(areaid, roleid, fatherid string) (errs DRuleError)
- func (o *OTransaction) WriteFriend(areaid, roleid, friendid string, bind int64) (errs DRuleError)
- func (o *OTransaction) WriteFriendStatus(areaid, roleid, friendid string, bindbit int, value interface{}) (errs DRuleError)
- func (o *OTransaction) WriteFriends(areaid, roleid string, friends map[string]roles.Status) (errs DRuleError)
- type O_Area
- type O_Area_User
- type O_AreasRouter
- type O_DRuleOperator
- type O_DRuleReceipt
- type O_DRuleUser
- type O_OperatorSend
- type O_RoleAndChild
- type O_RoleAndChildren
- type O_RoleAndContext
- type O_RoleAndContext_Data
- type O_RoleAndContexts
- type O_RoleAndFriend
- type O_RoleAndFriends
- type O_RoleData_Data
- type O_RoleFatherChange
- type O_RoleSendAndReceive
- type O_Transaction
- type OperateZone
- type Operator
- func NewOperator(tls bool, selfname string, addr string, conn_num int, ...) (o *Operator, err error)
- func NewOperatorNoTLS(selfname string, addr string, conn_num int, username, password string) (o *Operator, err error)
- func NewOperatorTLS(selfname string, addr string, conn_num int, username, password string) (o *Operator, err error)
- func (o *Operator) AreaAdd(area string) (errs DRuleError)
- func (o *Operator) AreaDel(area string) (errs DRuleError)
- func (o *Operator) AreaExist(area string) (exist bool, errs DRuleError)
- func (o *Operator) AreaList() (list []string, errs DRuleError)
- func (o *Operator) AreaRename(oldname, newname string) (errs DRuleError)
- func (o *Operator) AreaRouterDelete(areaname string) (errs DRuleError)
- func (o *Operator) AreaRouterList() (list []O_AreasRouter, errs DRuleError)
- func (o *Operator) AreaRouterSet(set O_AreasRouter) (errs DRuleError)
- func (o *Operator) Begin() (t *OTransaction, errs DRuleError)
- func (o *Operator) Close()
- func (o *Operator) CreateContext(areaid, roleid, contextname string) (errs DRuleError)
- func (o *Operator) DRuleModeGet() (mode DRuleOperateMode, errs DRuleError)
- func (o *Operator) DRuleOperatorDelete(name string) (errs DRuleError)
- func (o *Operator) DRuleOperatorList() (list []O_DRuleOperator, errs DRuleError)
- func (o *Operator) DRuleOperatorSet(name, address string, connnum int, tls bool, username, password string) (errs DRuleError)
- func (o *Operator) DRulePause() (errs DRuleError)
- func (o *Operator) DRuleStart() (errs DRuleError)
- func (o *Operator) DeleteChild(areaid, roleid, childid string) (errs DRuleError)
- func (o *Operator) DeleteContextBind(areaid, roleid, contextname string, upordown roles.ContextUpDown, ...) (errs DRuleError)
- func (o *Operator) DeleteFriend(areaid, roleid, friendid string) (errs DRuleError)
- func (o *Operator) DeleteRole(areaid, roleid string) (errs DRuleError)
- func (o *Operator) DropContext(areaid, roleid, contextname string) (errs DRuleError)
- func (o *Operator) ExistChild(areaid, roleid, childid string) (have bool, errs DRuleError)
- func (o *Operator) ExistContext(areaid, roleid, contextname string) (have bool, errs DRuleError)
- func (o *Operator) ExistRole(area, id string) (have bool, errs DRuleError)
- func (o *Operator) Password(username, password string) (errs DRuleError)
- func (o *Operator) ReadChildren(areaid, roleid string) (children []string, errs DRuleError)
- func (o *Operator) ReadContext(areaid, roleid, contextname string) (context roles.Context, have bool, errs DRuleError)
- func (o *Operator) ReadContextSameBind(areaid, roleid, contextname string, upordown roles.ContextUpDown, bind int64) (rolesid []string, have bool, errs DRuleError)
- func (o *Operator) ReadContextStatus(areaid, roleid, contextname string, upordown roles.ContextUpDown, ...) (have bool, errs DRuleError)
- func (o *Operator) ReadContexts(areaid, roleid string) (contexts map[string]roles.Context, errs DRuleError)
- func (o *Operator) ReadContextsName(areaid, roleid string) (names []string, errs DRuleError)
- func (o *Operator) ReadData(areaid, roleid, name string, data interface{}) (errs DRuleError)
- func (o *Operator) ReadDataToByte(areaid, roleid, name string) (data_b []byte, errs DRuleError)
- func (o *Operator) ReadFather(areaid, roleid string) (fatherid string, errs DRuleError)
- func (o *Operator) ReadFriendStatus(areaid, roleid, friendid string, bindbit int, value interface{}) (have bool, errs DRuleError)
- func (o *Operator) ReadFriends(areaid, roleid string) (firends map[string]roles.Status, errs DRuleError)
- func (o *Operator) ReadRole(area, id string, role roles.Roleer) (errs DRuleError)
- func (o *Operator) ReadRoleToMiddleData(area, id string) (md roles.RoleMiddleData, errs DRuleError)
- func (o *Operator) ResetChildren(areaid, roleid string) (errs DRuleError)
- func (o *Operator) ResetContexts(areaid, roleid string) (errs DRuleError)
- func (o *Operator) ResetFather(areaid, roleid string) (errs DRuleError)
- func (o *Operator) ResetFriends(areaid, roleid string) (errs DRuleError)
- func (o *Operator) StoreRole(area string, role roles.Roleer) (errs DRuleError)
- func (o *Operator) StoreRoleFromMiddleData(area string, rolemid roles.RoleMiddleData) (errs DRuleError)
- func (o *Operator) UserAdd(username, password, email string, authority UserAuthority) (errs DRuleError)
- func (o *Operator) UserAreaAlert(userid, areaname string, rw UserAreaVisit) (errs DRuleError)
- func (o *Operator) UserAreaDelete(userid, areaname string) (errs DRuleError)
- func (o *Operator) UserDel(username string) (errs DRuleError)
- func (o *Operator) UserList() (list []O_DRuleUser, errs DRuleError)
- func (o *Operator) UserLogin(username, password string) (errs DRuleError)
- func (o *Operator) UserLoginSha1(username, password string) (errs DRuleError)
- func (o *Operator) UserLogout() (errs DRuleError)
- func (o *Operator) WriteChild(areaid, roleid, childid string) (errs DRuleError)
- func (o *Operator) WriteChildren(areaid, roleid string, children []string) (errs DRuleError)
- func (o *Operator) WriteContext(areaid, roleid, contextname string, context roles.Context) (errs DRuleError)
- func (o *Operator) WriteContextStatus(areaid, roleid, contextname string, upordown roles.ContextUpDown, ...) (errs DRuleError)
- func (o *Operator) WriteContexts(areaid, roleid string, contexts map[string]roles.Context) (errs DRuleError)
- func (o *Operator) WriteData(areaid, roleid, name string, data interface{}) (errs DRuleError)
- func (o *Operator) WriteDataFromByte(areaid, roleid, name string, data_b []byte) (errs DRuleError)
- func (o *Operator) WriteFather(areaid, roleid, fatherid string) (errs DRuleError)
- func (o *Operator) WriteFriend(areaid, roleid, friendid string, bind int64) (errs DRuleError)
- func (o *Operator) WriteFriendStatus(areaid, roleid, friendid string, bindbit int, value interface{}) (errs DRuleError)
- func (o *Operator) WriteFriends(areaid, roleid string, friends map[string]roles.Status) (errs DRuleError)
- type OperatorType
- type TransactionAskFor
- type UserAreaVisit
- type UserAuthority
Constants ¶
const ( // 运行状态 OPERATOR_RUN_NO = iota // 未指定 OPERATOR_RUN_RUNNING // 正在运行 OPERATOR_RUN_CLOSEING // 正在停止 OPERATOR_RUN_CLOSED // 已经停止 )
const ( USER_ADD_LIFE = 3000 // 续命间隔时间(单位秒),不要大于USER_ALIVE_TIME USER_ALIVE_TIME = 3600 // 用户的登录生存期(单位秒) )
几个时间
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DRuleError ¶
type DRuleError struct { Code DRuleReturnStatus Err error }
func NewDRuleError ¶
func NewDRuleError() (err DRuleError)
type DRuleOperateMode ¶
type DRuleOperateMode uint8
DRule工作模式
const ( DRULE_OPERATE_MODE_SLAVE DRuleOperateMode = iota // 从机模式 DRULE_OPERATE_MODE_MASTER // 主机模式 )
type DRuleReturnStatus ¶
type DRuleReturnStatus uint
const ( // 数据没有任何的状态 DATA_NO_RETRUN DRuleReturnStatus = iota // 数据并不是期望的 DATA_NOT_EXPECT // 数据一切正常 DATA_ALL_OK // 数据终止 DATA_END // 请发送数据 DATA_PLEASE // 数据将发送 DATA_WILL_SEND // 数据返回有错误 DATA_RETURN_ERROR // 数据返回为True DATA_RETURN_IS_TRUE // 数据返回为flase DATA_RETURN_IS_FALSE // 事务找不到 DATA_TRAN_NOT_EXIST // 事务错误 DATA_TRAN_ERROR // DRule已经关闭 DATA_DRULE_CLOSED // DRule没有暂停 DATA_DRULE_NOT_PAUSED // 用户没有登录 DATA_USER_NOT_LOGIN // 用户重复 DATA_USER_EXIST // 用户不存在 DATA_USER_NO_EXIST // 用户密码错误 DATA_USER_PASSWORD_WRONG // 用户没有权限 DATA_USER_NO_AUTHORITY // 用户没有区域权限 DATA_USER_NO_AREA_AUTHORITY // 区域存在 DATA_AREA_EXIST // 区域不存在 DATA_AREA_NO_EXIST // Drule的operator存在 DATA_DRULE_OPERATOR_EXIST // Drule的operator不存在 DATA_DRULE_OPERATOR_NO_EXIST )
数据标记状态
type OTransaction ¶
type OTransaction struct {
// contains filtered or unexported fields
}
操作机事务
func (*OTransaction) CreateContext ¶
func (o *OTransaction) CreateContext(areaid, roleid, contextname string) (errs DRuleError)
创建一个空上下文
func (*OTransaction) DeleteChild ¶
func (o *OTransaction) DeleteChild(areaid, roleid, childid string) (errs DRuleError)
删除一个子角色
func (*OTransaction) DeleteContextBind ¶
func (o *OTransaction) DeleteContextBind(areaid, roleid, contextname string, upordown roles.ContextUpDown, bindrole string) (errs DRuleError)
删除一个上下文绑定
func (*OTransaction) DeleteFriend ¶
func (o *OTransaction) DeleteFriend(areaid, roleid, friendid string) (errs DRuleError)
删除一个朋友关系
func (*OTransaction) DeleteRole ¶
func (o *OTransaction) DeleteRole(areaid, roleid string) (errs DRuleError)
删除角色
func (*OTransaction) DropContext ¶
func (o *OTransaction) DropContext(areaid, roleid, contextname string) (errs DRuleError)
清除一个上下文
func (*OTransaction) ExistChild ¶
func (o *OTransaction) ExistChild(areaid, roleid, childid string) (have bool, errs DRuleError)
是否拥有这个子角色
func (*OTransaction) ExistContext ¶
func (o *OTransaction) ExistContext(areaid, roleid, contextname string) (have bool, errs DRuleError)
查看是否有这个上下文
func (*OTransaction) ExistRole ¶
func (o *OTransaction) ExistRole(area, id string) (have bool, errs DRuleError)
是否存在这个角色
func (*OTransaction) LockRole ¶
func (o *OTransaction) LockRole(areaid string, roleids ...string) (errs DRuleError)
准备锁定角色
func (*OTransaction) ReadChildren ¶
func (o *OTransaction) ReadChildren(areaid, roleid string) (children []string, errs DRuleError)
读取所有子角色名
func (*OTransaction) ReadContext ¶
func (o *OTransaction) ReadContext(areaid, roleid, contextname string) (context roles.Context, have bool, errs DRuleError)
返回某个上下文的全部信息
func (*OTransaction) ReadContextSameBind ¶
func (o *OTransaction) ReadContextSameBind(areaid, roleid, contextname string, upordown roles.ContextUpDown, bind int64) (rolesid []string, have bool, errs DRuleError)
获取同一个上下文的同一个绑定值的所有角色id
func (*OTransaction) ReadContextStatus ¶
func (o *OTransaction) ReadContextStatus(areaid, roleid, contextname string, upordown roles.ContextUpDown, bindrole string, bindbit int, value interface{}) (have bool, errs DRuleError)
获取一个上下文的状态
func (*OTransaction) ReadContexts ¶
func (o *OTransaction) ReadContexts(areaid, roleid string) (contexts map[string]roles.Context, errs DRuleError)
获取完全上下文
func (*OTransaction) ReadContextsName ¶
func (o *OTransaction) ReadContextsName(areaid, roleid string) (names []string, errs DRuleError)
返回所有上下文组的名称
func (*OTransaction) ReadData ¶
func (o *OTransaction) ReadData(areaid, roleid, name string, data interface{}) (errs DRuleError)
读取数据
func (*OTransaction) ReadDataToByte ¶
func (o *OTransaction) ReadDataToByte(areaid, roleid, name string) (data_b []byte, errs DRuleError)
读取数据
func (*OTransaction) ReadFather ¶
func (o *OTransaction) ReadFather(areaid, roleid string) (fatherid string, errs DRuleError)
读角色的父亲
func (*OTransaction) ReadFriendStatus ¶
func (o *OTransaction) ReadFriendStatus(areaid, roleid, friendid string, bindbit int, value interface{}) (have bool, errs DRuleError)
读取朋友的状态
func (*OTransaction) ReadFriends ¶
func (o *OTransaction) ReadFriends(areaid, roleid string) (firends map[string]roles.Status, errs DRuleError)
读取所有朋友关系
func (*OTransaction) ReadRole ¶
func (o *OTransaction) ReadRole(area, id string, role roles.Roleer) (errs DRuleError)
读取角色
func (*OTransaction) ReadRoleToMiddleData ¶
func (o *OTransaction) ReadRoleToMiddleData(area, id string) (md roles.RoleMiddleData, errs DRuleError)
读取角色到中间格式
func (*OTransaction) ResetChildren ¶
func (o *OTransaction) ResetChildren(areaid, roleid string) (errs DRuleError)
重置子角色
func (*OTransaction) ResetContexts ¶
func (o *OTransaction) ResetContexts(areaid, roleid string) (errs DRuleError)
重置上下文
func (*OTransaction) ResetFather ¶
func (o *OTransaction) ResetFather(areaid, roleid string) (errs DRuleError)
重置父角色
func (*OTransaction) ResetFriends ¶
func (o *OTransaction) ResetFriends(areaid, roleid string) (errs DRuleError)
重置所有朋友关系
func (*OTransaction) StoreRole ¶
func (o *OTransaction) StoreRole(area string, role roles.Roleer) (errs DRuleError)
存入角色
func (*OTransaction) StoreRoleFromMiddleData ¶
func (o *OTransaction) StoreRoleFromMiddleData(area string, rolemid roles.RoleMiddleData) (errs DRuleError)
存入角色
func (*OTransaction) WriteChild ¶
func (o *OTransaction) WriteChild(areaid, roleid, childid string) (errs DRuleError)
写一个子角色
func (*OTransaction) WriteChildren ¶
func (o *OTransaction) WriteChildren(areaid, roleid string, children []string) (errs DRuleError)
写入所有子角色名
func (*OTransaction) WriteContext ¶
func (o *OTransaction) WriteContext(areaid, roleid, contextname string, context roles.Context) (errs DRuleError)
写一个上下文
func (*OTransaction) WriteContextStatus ¶
func (o *OTransaction) WriteContextStatus(areaid, roleid, contextname string, upordown roles.ContextUpDown, bindrole string, bindbit int, value interface{}) (errs DRuleError)
设定上下文的状态
func (*OTransaction) WriteContexts ¶
func (o *OTransaction) WriteContexts(areaid, roleid string, contexts map[string]roles.Context) (errs DRuleError)
设定完全上下文
func (*OTransaction) WriteData ¶
func (o *OTransaction) WriteData(areaid, roleid, name string, data interface{}) (errs DRuleError)
写入数据
func (*OTransaction) WriteDataFromByte ¶
func (o *OTransaction) WriteDataFromByte(areaid, roleid, name string, data_b []byte) (errs DRuleError)
写入数据
func (*OTransaction) WriteFather ¶
func (o *OTransaction) WriteFather(areaid, roleid, fatherid string) (errs DRuleError)
设置父角色
func (*OTransaction) WriteFriend ¶
func (o *OTransaction) WriteFriend(areaid, roleid, friendid string, bind int64) (errs DRuleError)
写入一个朋友
func (*OTransaction) WriteFriendStatus ¶
func (o *OTransaction) WriteFriendStatus(areaid, roleid, friendid string, bindbit int, value interface{}) (errs DRuleError)
设置朋友状态
func (*OTransaction) WriteFriends ¶
func (o *OTransaction) WriteFriends(areaid, roleid string, friends map[string]roles.Status) (errs DRuleError)
写入所有朋友关系
type O_Area_User ¶
type O_Area_User struct { UserName string // 用户名 Area string // 区域名 WRable bool // true为读权限,false为写权限 Add bool // true为增加,false为减少 }
用户和区域的权限
type O_AreasRouter ¶
type O_AreasRouter struct { AreaName string // 区域名称 Mirror bool // 是否为镜像,ture为镜像,则所有的文件都发给下面所有的drule Mirrors []string // string为drule的名字 Chars map[string][]string // 如果mirror为false,则看这个根据不同的字母进行路由,第一个stirng为首字母,第二个string为operator的名称 }
蔓延到其他drule上的区域
type O_DRuleOperator ¶
type O_DRuleOperator struct { Name string // 名称 Address string // 地址与端口 ConnNum int // 连接数 TLS bool // 是否加密 Username string // 用户名 Password string // 密码 }
远端操作者的记录
type O_DRuleReceipt ¶
type O_DRuleReceipt struct { DataStat DRuleReturnStatus // 数据状态,来自DATA_* Error string // 返回的错误 Data []byte // 数据体 }
DRule回执带数据体
type O_DRuleUser ¶
type O_DRuleUser struct { UserName string // 用户名 Password string // 密码 Email string // 邮箱 Authority UserAuthority // 权限,USER_AUTHORITY_* Unid string // 唯一码 }
来往网络的用户信息
type O_OperatorSend ¶
type O_OperatorSend struct { OperateZone OperateZone // 操作分区 Operate OperatorType // 操作类型,从OPERATE_* OperatorName string // 客户端名称 InTransaction bool // 在事务中 TransactionId string // 事务ID RoleId string // 涉及到的角色id AreaId string // 涉及到的区域ID User string // 登陆的用户名 Unid string // 登录的Unid Data []byte // 数据体 }
Operator的发送
type O_RoleAndChild ¶
角色的单个子角色关系的网络数据格式
type O_RoleAndChildren ¶
角色的所有子角色
type O_RoleAndContext ¶
type O_RoleAndContext struct { Area string Id string // 上下文的名字 Context string // 这是roles包中的CONTEXT_UP或CONTEXT_DOWN UpOrDown roles.ContextUpDown // 要操作的绑定角色的ID BindRole string // 存在否 Exist bool }
角色的单个上下文关系的网络数据格式
type O_RoleAndContext_Data ¶
type O_RoleAndContext_Data struct { Area string Id string // 上下文的名字 Context string // 要求的上下文是否存在 Exist bool // 这是roles包中的CONTEXT_UP或CONTEXT_DOWN UpOrDown roles.ContextUpDown // 要操作的绑定角色的ID BindRole string // 一个的状态位结构 Status roles.Status // 上下文的结构 ContextBody roles.Context // 名字等的集合 Gather []string // 单一的绑定属性修改,1为int,2为float,3为complex Single roles.StatusValueType // 单一的绑定修改所对应的位置,也就是0到9 Bit int // 单一修改的Int Int int64 // 单一修改的Float Float float64 // 单一修改的Complex Complex complex128 // 单一修改的string String string }
角色的单个上下文关系数据的网络数据格式
type O_RoleAndContexts ¶
角色的全部上下文
type O_RoleAndFriend ¶
type O_RoleAndFriend struct { Area string Id string Friend string Bind int64 // 要求的是否存在 Exist bool Status roles.Status // 单一的绑定属性修改,1为int,2为float,3为complex Single roles.StatusValueType // 单一的绑定修改所对应的位置,也就是0到9 Bit int // 单一修改的Int Int int64 // 单一修改的Float Float float64 // 单一修改的Complex Complex complex128 // 单一修改的string String string }
角色的单个朋友角色关系的网络数据格式
type O_RoleAndFriends ¶
角色的所有朋友
type O_RoleData_Data ¶
type O_RoleData_Data struct { Area string Id string // 数据点的名字 Name string // 数据类型 Type string // 数据的字节流 Data []byte }
角色的单个数据的数据体的网络格式
type O_RoleFatherChange ¶
角色的father修改的数据格式
type O_RoleSendAndReceive ¶
type O_RoleSendAndReceive struct { Area string // 区域 RoleID string // 角色的ID IfHave bool // 是否存在 RoleBody roles.RoleMiddleData // 角色的身体 }
角色的接收与发送格式
type O_Transaction ¶
type O_Transaction struct { TransactionId string // 事务的ID InTransaction bool // 是否在事务中 Area string // 区域 PrepareIDs []string // 准备的角色ID }
对事务的数据
type OperateZone ¶
type OperateZone uint
操作的区域划分
const ( OPERATE_ZONE_NOTHING OperateZone = iota // 什么都没有 OPERATE_ZONE_NORMAL // 用户 OPERATE_ZONE_SYSTEM // 系统操作 OPERATE_ZONE_MANAGE // 管理 )
type Operator ¶
type Operator struct {
// contains filtered or unexported fields
}
这叫做“操作机”,是用来远程连接DRule的。
func NewOperator ¶
func NewOperatorNoTLS ¶
func NewOperatorNoTLS(selfname string, addr string, conn_num int, username, password string) (o *Operator, err error)
创建一个操作者,自己的名字,远程地址,连接数,用户名,密码,日志
func NewOperatorTLS ¶
func NewOperatorTLS(selfname string, addr string, conn_num int, username, password string) (o *Operator, err error)
创建一个操作者,并使用加密连接。自己的名字,远程地址,连接数,用户名,密码,日志
func (*Operator) AreaExist ¶
func (o *Operator) AreaExist(area string) (exist bool, errs DRuleError)
区域是否存在
func (*Operator) AreaRename ¶
func (o *Operator) AreaRename(oldname, newname string) (errs DRuleError)
重命名区域
func (*Operator) AreaRouterDelete ¶
func (o *Operator) AreaRouterDelete(areaname string) (errs DRuleError)
删除远端区域的路由
func (*Operator) AreaRouterList ¶
func (o *Operator) AreaRouterList() (list []O_AreasRouter, errs DRuleError)
返回所有区域路由的信息
func (*Operator) AreaRouterSet ¶
func (o *Operator) AreaRouterSet(set O_AreasRouter) (errs DRuleError)
设置远端区域的路由
func (*Operator) CreateContext ¶
func (o *Operator) CreateContext(areaid, roleid, contextname string) (errs DRuleError)
创建一个空上下文
func (*Operator) DRuleModeGet ¶
func (o *Operator) DRuleModeGet() (mode DRuleOperateMode, errs DRuleError)
返回Drule的工作模式
func (*Operator) DRuleOperatorDelete ¶
func (o *Operator) DRuleOperatorDelete(name string) (errs DRuleError)
删除DRule的一个远程Operator
func (*Operator) DRuleOperatorList ¶
func (o *Operator) DRuleOperatorList() (list []O_DRuleOperator, errs DRuleError)
返回DRule上远端Operator的列表
func (*Operator) DRuleOperatorSet ¶
func (o *Operator) DRuleOperatorSet(name, address string, connnum int, tls bool, username, password string) (errs DRuleError)
给DRule添加一个Operator
func (*Operator) DeleteChild ¶
func (o *Operator) DeleteChild(areaid, roleid, childid string) (errs DRuleError)
删除一个子角色
func (*Operator) DeleteContextBind ¶
func (o *Operator) DeleteContextBind(areaid, roleid, contextname string, upordown roles.ContextUpDown, bindrole string) (errs DRuleError)
删除一个上下文绑定
func (*Operator) DeleteFriend ¶
func (o *Operator) DeleteFriend(areaid, roleid, friendid string) (errs DRuleError)
删除一个朋友关系
func (*Operator) DeleteRole ¶
func (o *Operator) DeleteRole(areaid, roleid string) (errs DRuleError)
删除角色
func (*Operator) DropContext ¶
func (o *Operator) DropContext(areaid, roleid, contextname string) (errs DRuleError)
清除一个上下文
func (*Operator) ExistChild ¶
func (o *Operator) ExistChild(areaid, roleid, childid string) (have bool, errs DRuleError)
是否拥有这个子角色
func (*Operator) ExistContext ¶
func (o *Operator) ExistContext(areaid, roleid, contextname string) (have bool, errs DRuleError)
查看是否有这个上下文
func (*Operator) ExistRole ¶
func (o *Operator) ExistRole(area, id string) (have bool, errs DRuleError)
是否存在这个角色
func (*Operator) Password ¶
func (o *Operator) Password(username, password string) (errs DRuleError)
设置或修改用户的密码
func (*Operator) ReadChildren ¶
func (o *Operator) ReadChildren(areaid, roleid string) (children []string, errs DRuleError)
读取所有子角色名
func (*Operator) ReadContext ¶
func (o *Operator) ReadContext(areaid, roleid, contextname string) (context roles.Context, have bool, errs DRuleError)
返回某个上下文的全部信息
func (*Operator) ReadContextSameBind ¶
func (o *Operator) ReadContextSameBind(areaid, roleid, contextname string, upordown roles.ContextUpDown, bind int64) (rolesid []string, have bool, errs DRuleError)
获取同一个上下文的同一个绑定值的所有角色id
func (*Operator) ReadContextStatus ¶
func (o *Operator) ReadContextStatus(areaid, roleid, contextname string, upordown roles.ContextUpDown, bindrole string, bindbit int, value interface{}) (have bool, errs DRuleError)
获取一个上下文的状态
func (*Operator) ReadContexts ¶
func (o *Operator) ReadContexts(areaid, roleid string) (contexts map[string]roles.Context, errs DRuleError)
获取完全上下文
func (*Operator) ReadContextsName ¶
func (o *Operator) ReadContextsName(areaid, roleid string) (names []string, errs DRuleError)
返回所有上下文组的名称
func (*Operator) ReadData ¶
func (o *Operator) ReadData(areaid, roleid, name string, data interface{}) (errs DRuleError)
读取数据
func (*Operator) ReadDataToByte ¶
func (o *Operator) ReadDataToByte(areaid, roleid, name string) (data_b []byte, errs DRuleError)
读取数据
func (*Operator) ReadFather ¶
func (o *Operator) ReadFather(areaid, roleid string) (fatherid string, errs DRuleError)
读角色的父亲
func (*Operator) ReadFriendStatus ¶
func (o *Operator) ReadFriendStatus(areaid, roleid, friendid string, bindbit int, value interface{}) (have bool, errs DRuleError)
读取朋友的状态
func (*Operator) ReadFriends ¶
func (o *Operator) ReadFriends(areaid, roleid string) (firends map[string]roles.Status, errs DRuleError)
读取所有朋友关系
func (*Operator) ReadRole ¶
func (o *Operator) ReadRole(area, id string, role roles.Roleer) (errs DRuleError)
读取角色
func (*Operator) ReadRoleToMiddleData ¶
func (o *Operator) ReadRoleToMiddleData(area, id string) (md roles.RoleMiddleData, errs DRuleError)
读角色到中间数据格式
func (*Operator) ResetChildren ¶
func (o *Operator) ResetChildren(areaid, roleid string) (errs DRuleError)
重置子角色
func (*Operator) ResetContexts ¶
func (o *Operator) ResetContexts(areaid, roleid string) (errs DRuleError)
重置上下文
func (*Operator) ResetFather ¶
func (o *Operator) ResetFather(areaid, roleid string) (errs DRuleError)
重置父角色
func (*Operator) ResetFriends ¶
func (o *Operator) ResetFriends(areaid, roleid string) (errs DRuleError)
重置所有朋友关系
func (*Operator) StoreRole ¶
func (o *Operator) StoreRole(area string, role roles.Roleer) (errs DRuleError)
存入角色
func (*Operator) StoreRoleFromMiddleData ¶
func (o *Operator) StoreRoleFromMiddleData(area string, rolemid roles.RoleMiddleData) (errs DRuleError)
保存角色
func (*Operator) UserAdd ¶
func (o *Operator) UserAdd(username, password, email string, authority UserAuthority) (errs DRuleError)
增加用户
func (*Operator) UserAreaAlert ¶
func (o *Operator) UserAreaAlert(userid, areaname string, rw UserAreaVisit) (errs DRuleError)
添加(更新)一个用户对区域的访问权限
func (*Operator) UserAreaDelete ¶
func (o *Operator) UserAreaDelete(userid, areaname string) (errs DRuleError)
删除一个用户对区域的访问权限
func (*Operator) UserList ¶
func (o *Operator) UserList() (list []O_DRuleUser, errs DRuleError)
列出所有用户
func (*Operator) UserLogin ¶
func (o *Operator) UserLogin(username, password string) (errs DRuleError)
用户登陆
func (*Operator) UserLoginSha1 ¶
func (o *Operator) UserLoginSha1(username, password string) (errs DRuleError)
用户登录(sha1password)
func (*Operator) WriteChild ¶
func (o *Operator) WriteChild(areaid, roleid, childid string) (errs DRuleError)
写一个子角色
func (*Operator) WriteChildren ¶
func (o *Operator) WriteChildren(areaid, roleid string, children []string) (errs DRuleError)
写入所有子角色名
func (*Operator) WriteContext ¶
func (o *Operator) WriteContext(areaid, roleid, contextname string, context roles.Context) (errs DRuleError)
写一个上下文
func (*Operator) WriteContextStatus ¶
func (o *Operator) WriteContextStatus(areaid, roleid, contextname string, upordown roles.ContextUpDown, bindrole string, bindbit int, value interface{}) (errs DRuleError)
设定上下文的状态
func (*Operator) WriteContexts ¶
func (o *Operator) WriteContexts(areaid, roleid string, contexts map[string]roles.Context) (errs DRuleError)
设定完全上下文
func (*Operator) WriteData ¶
func (o *Operator) WriteData(areaid, roleid, name string, data interface{}) (errs DRuleError)
写入数据
func (*Operator) WriteDataFromByte ¶
func (o *Operator) WriteDataFromByte(areaid, roleid, name string, data_b []byte) (errs DRuleError)
写入数据
func (*Operator) WriteFather ¶
func (o *Operator) WriteFather(areaid, roleid, fatherid string) (errs DRuleError)
设置父角色
func (*Operator) WriteFriend ¶
func (o *Operator) WriteFriend(areaid, roleid, friendid string, bind int64) (errs DRuleError)
写入一个朋友
func (*Operator) WriteFriendStatus ¶
func (o *Operator) WriteFriendStatus(areaid, roleid, friendid string, bindbit int, value interface{}) (errs DRuleError)
设置朋友状态
func (*Operator) WriteFriends ¶
func (o *Operator) WriteFriends(areaid, roleid string, friends map[string]roles.Status) (errs DRuleError)
写入所有朋友关系
type OperatorType ¶
type OperatorType uint
OperatorType是Operator向Drule请求的操作类型
const ( // 什么操作都没有 OPERATE_NOTHING OperatorType = iota // 强制保存 OPERATE_TOSTORE // 获取一个角色 OPERATE_READ_ROLE // 写入一个角色 OPERATE_WRITE_ROLE // 存在一个角色 OPERATE_EXIST_ROLE // 创建一个新角色 OPERATE_NEW_ROLE // 删除一个角色 OPERATE_DEL_ROLE // 获取角色的一个值 OPERATE_GET_DATA // 设置角色的一个值 OPERATE_SET_DATA // 设置father OPERATE_SET_FATHER // 获取father OPERATE_GET_FATHER // 重置father OPERATE_RESET_FATHER // 设置children OPERATE_SET_CHILDREN // 获取children OPERATE_GET_CHILDREN // 重置children OPERATE_RESET_CHILDREN // 添加一个child OPERATE_ADD_CHILD // 删除一个child OPERATE_DEL_CHILD // 存在某个child OPERATE_EXIST_CHILD // 设置friends OPERATE_SET_FRIENDS // 获取friends OPERATE_GET_FRIENDS // 重置friends OPERATE_RESET_FRIENDS // 添加一个friend OPERATE_ADD_FRIEND // 删除一个friend OPERATE_DEL_FRIEND // 修改一个friend OPERATE_CHANGE_FRIEND // 获取同样绑定值的friend OPERATE_SAME_BIND_FRIEND // 添加一个空的上下文组 OPERATE_ADD_CONTEXT // 是否有这个上下文 OPERATE_EXIST_CONTEXT // 删除一个上下文组 OPERATE_DROP_CONTEXT // 获取所有上下文的名称 OPERATE_GET_CONTEXTS_NAME // 读取一个上下文的全部 OPERATE_READ_CONTEXT // 获取一个上下文中同样绑定值的角色id OPERATE_SAME_BIND_CONTEXT // 写入一个上下文的全部 OPERATE_WRITE_CONTEXT // 添加一个上下文绑定 OPERATE_ADD_CONTEXT_BIND // 删除一个上下文绑定 OPERATE_DEL_CONTEXT_BIND // 修改一个上下文的绑定 OPERATE_CHANGE_CONTEXT_BIND // 返回上下文中同样绑定的元素 OPERATE_CONTEXT_SAME_BIND // 添加一个上文 OPERATE_ADD_CONTEXT_UP // 删除上文 OPERATE_DEL_CONTEXT_UP // 修改上文 OPERATE_CHANGE_CONTEXT_UP // 返回同样绑定的上文 OPERATE_SAME_BIND_CONTEXT_UP // 添加一个下文 OPERATE_ADD_CONTEXT_DOWN // 删除下文 OPERATE_DEL_CONTEXT_DOWN // 修改下文 OPERATE_CHANGE_CONTEXT_DOWN // 返回同样绑定的下文 OPERATE_SAME_BIND_CONTEXT_DOWN // 设置朋友的状态 OPERATE_SET_FRIEND_STATUS // 获取朋友的状态 OPERATE_GET_FRIEND_STATUS // 设置上下文的状态 OPERATE_SET_CONTEXT_STATUS // 获取上下文的状态 OPERATE_GET_CONTEXT_STATUS // 设置contexts OPERATE_SET_CONTEXTS // 获取contexts OPERATE_GET_CONTEXTS // 重置contexts OPERATE_RESET_CONTEXTS // 启动事务 OPERATE_TRAN_BEGIN // 回滚事务 OPERATE_TRAN_ROLLBACK // 执行事务 OPERATE_TRAN_COMMIT // 事务错误 OPERATE_TRAN_ERROR // 准备事务 OPERATE_TRAN_PREPARE // 用户登录 OPERATE_USER_LOGIN // 检查登录 OPERATE_USER_CHECK_LOGIN // 用户续命 OPERATE_USER_ADD_LIFE // 用户新建 OPERATE_USER_ADD // 用户改密码 OPERATE_USER_PASSWORD // 更改用户邮箱 OPERATE_USER_EMAIL // 用户删除 OPERATE_USER_DEL // 用户登出 OPERATE_USER_LOGOUT // 用户列表 OPERATE_USER_LIST // 添加区域 OPERATE_AREA_ADD // 删除区域 OPERATE_AREA_DEL // 修改区域名称 OPERATE_AREA_RENAME // 区域是否存在 OPERATE_AREA_EXIST // 区域列表 OPERATE_AREA_LIST // 用户和区域的关系 OPERATE_USER_AREA // 对远程Operator的设置 OPERATE_DRULE_OPERATOR_SET // 对远程Operator的删除 OPERATE_DRULE_OPERATOR_DELETE // 对远程Operator的列表 OPERATE_DRULE_OPERATOR_LIST // 对角色远端路由的设置 OPERATE_AREA_ROUTER_SET // 对角色远端路由的删除 OPERATE_AREA_ROUTER_DELETE // 对角色远端路由的列表 OPERATE_AREA_ROUTER_LIST /* 下面对应OPERATE_ZONE_SYSTEM */ // DRule的工作模式 OPERATE_DRULE_OPERATE_MODE // DRule启动 OPERATE_DRULE_START // DRule暂停 OPERATE_DRULE_PAUSE )
这是OperatorType所可以使用的值
type TransactionAskFor ¶
type TransactionAskFor uint8
事务的请求操作
const ( TRANSACTION_ASKFOR_NO TransactionAskFor = iota // 事务没有请求 TRANSACTION_ASKFOR_END // 事务请求终止(rollback或commit) TRANSACTION_ASKFOR_KEEPLIVE // 事务续期 )
type UserAreaVisit ¶
type UserAreaVisit uint8
用户区域访问权限
const ( USER_AREA_VISIT_READONLY UserAreaVisit = iota // 只读 USER_AREA_VISIT_WRITABLE // 可写 )
type UserAuthority ¶
type UserAuthority uint8
用户权限
const ( USER_AUTHORITY_NO UserAuthority = iota // 没有权限 USER_AUTHORITY_ROOT // 根权限 USER_AUTHORITY_DRULE // DRule设备 USER_AUTHORITY_NORMAL // 普通权限 )