store

package
v0.0.0-...-7c4c28a Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: Apache-2.0 Imports: 11 Imported by: 6

Documentation

Index

Constants

View Source
const (
	STORE_SAVE_TIMER   = iota + 1 // 定时保存
	STORE_SAVE_OFFLINE            // 离线保存
)
View Source
const (
	ERR_STORE_NONE              = 11000 + iota
	ERR_STORE_SQL               // sql 错误
	ERR_STORE_NOROW             // 没有查找到记录
	ERR_STORE_ROLE_INDEX        // 索引错误
	ERR_STORE_ROLE_NOT_FOUND    // 玩家没找到
	ERR_STORE_ROLE_STATUS_ERROR // 玩家状态错误
	ERR_STORE_ROLE_DELETED      // 角色已经删除
	ERR_STORE_ROLE_NAME         // 角色名重复
	ERR_STORE_SAVE_FAILED       // 角色存档失败
	ERR_STORE_ERROR             // 其它错误
)

存储错误码

View Source
const (
	STORE_CLIENT = iota + 1
	STORE_SERVER
)

Variables

View Source
var (
	ErrNoRows      = errors.New("no row found")
	ErrObject      = errors.New("object type error")
	ErrNoCondition = errors.New("get condition is empty")
)

Functions

func ParseDeleteReply

func ParseDeleteReply(err *rpc.Error, ar *utils.LoadArchive) (*rpc.Error, int64)

返回值:err *rpc.Error,affected int64

func ParseExecReply

func ParseExecReply(err *rpc.Error, ar *utils.LoadArchive) (*rpc.Error, int64)

返回值:err *rpc.Error, affected int64

func ParseFindReply

func ParseFindReply(err *rpc.Error, ar *utils.LoadArchive, object interface{}) *rpc.Error

func ParseGetReply

func ParseGetReply(err *rpc.Error, ar *utils.LoadArchive, object interface{}) *rpc.Error

ParseGetReply 解析查询回调的参数

func ParseInsertReply

func ParseInsertReply(err *rpc.Error, ar *utils.LoadArchive) (*rpc.Error, int64, int64)

返回值:err, affected, id

func ParseMultiInsertReply

func ParseMultiInsertReply(err *rpc.Error, ar *utils.LoadArchive) *rpc.Error

返回值:err

func ParseQueryReply

func ParseQueryReply(err *rpc.Error, ar *utils.LoadArchive) (*rpc.Error, []map[string][]byte)

返回值:err *rpc.Error, result []map[string][]byte

func ParseUpdateReply

func ParseUpdateReply(err *rpc.Error, ar *utils.LoadArchive) (*rpc.Error, int64)

返回值:err *rpc.Error, affected int6

Types

type Extension

type Extension interface {
	RegisterCallback(svr rpc.Servicer)
}

type Register

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

func (*Register) Create

func (r *Register) Create(name string) interface{}

func (*Register) CreateSlice

func (r *Register) CreateSlice(name string) interface{}

func (*Register) Register

func (r *Register) Register(name string, obj interface{}, objslice interface{}) error

func (*Register) Sync

func (r *Register) Sync(ctx *StoreModule) error

type Sql

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

func (*Sql) Init

func (s *Sql) Init(core service.CoreAPI) (err error)

func (*Sql) Session

func (s *Sql) Session() *xorm.Session

func (*Sql) Sync

func (s *Sql) Sync(bean interface{}) error

type Store

type Store struct {
	*rpc.Thread
	// contains filtered or unexported fields
}

func NewStore

func NewStore(ctx *StoreModule) *Store

func (*Store) AddExtension

func (s *Store) AddExtension(name string, ext Extension)

func (*Store) Delete

func (s *Store) Delete(sender, _ rpc.Mailbox, msg *protocol.Message) (errcode int32, reply *protocol.Message)

func (*Store) Delete2

func (s *Store) Delete2(sender, _ rpc.Mailbox, msg *protocol.Message) (errcode int32, reply *protocol.Message)

func (*Store) Delete3

func (s *Store) Delete3(sender, _ rpc.Mailbox, msg *protocol.Message) (errcode int32, reply *protocol.Message)

func (*Store) Exec

func (s *Store) Exec(sender, _ rpc.Mailbox, msg *protocol.Message) (errcode int32, reply *protocol.Message)

func (*Store) Find

func (s *Store) Find(sender, _ rpc.Mailbox, msg *protocol.Message) (errcode int32, reply *protocol.Message)

func (*Store) Get

func (s *Store) Get(sender, _ rpc.Mailbox, msg *protocol.Message) (errcode int32, reply *protocol.Message)

func (*Store) Insert

func (s *Store) Insert(sender, _ rpc.Mailbox, msg *protocol.Message) (errcode int32, reply *protocol.Message)

func (*Store) MultiInsert

func (s *Store) MultiInsert(sender, _ rpc.Mailbox, msg *protocol.Message) (errcode int32, reply *protocol.Message)

func (*Store) MultiUpdate

func (s *Store) MultiUpdate(sender, _ rpc.Mailbox, msg *protocol.Message) (errcode int32, reply *protocol.Message)

func (*Store) Query

func (s *Store) Query(sender, _ rpc.Mailbox, msg *protocol.Message) (errcode int32, reply *protocol.Message)

func (*Store) RegisterCallback

func (s *Store) RegisterCallback(svr rpc.Servicer)

func (*Store) Update

func (s *Store) Update(sender, _ rpc.Mailbox, msg *protocol.Message) (errcode int32, reply *protocol.Message)

type StoreClient

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

func NewStoreClient

func NewStoreClient(ctx *StoreModule) *StoreClient

func (*StoreClient) Custom

func (s *StoreClient) Custom(identity interface{}, reply rpc.ReplyCB, method string, args ...interface{}) error

批量插入,identity为返回的标识符,typ查询的object数据类型集合,object待插入的数据集合

func (*StoreClient) Delete

func (s *StoreClient) Delete(identity interface{}, typ string, id int64, reply rpc.ReplyCB) error

删除一条记录,identity为返回的标识符,typ查询的数据类型,待删除对象的id

func (*StoreClient) DeleteByObject

func (s *StoreClient) DeleteByObject(identity interface{}, typ string, object interface{}, reply rpc.ReplyCB) error

删除一条记录,identity为返回的标识符,typ查询的数据类型,object待删除的数据(非零值为条件)

func (*StoreClient) Exec

func (s *StoreClient) Exec(identity interface{}, sql string, args []interface{}, reply rpc.ReplyCB) error

执行原生sql语句,identity为返回的标识符,sql为执行语句,args是参数

func (*StoreClient) Find

func (s *StoreClient) Find(identity interface{}, typ string, condition map[string]interface{}, limit int, start int, reply rpc.ReplyCB) error

查找多条记录,identity为返回的标识符,typ查询的数据类型,condition为条件{column:value},

func (*StoreClient) Get

func (s *StoreClient) Get(identity interface{}, typ string, condition map[string]interface{}, reply rpc.ReplyCB) error

Get 查询单条记录,identity为返回的标识符,typ查询的数据类型,condition为条件{column:value}

func (*StoreClient) Insert

func (s *StoreClient) Insert(identity interface{}, typ string, object interface{}, reply rpc.ReplyCB) error

查找一条记录,tag为返回的标识符,typ查询的数据类型,object待插入的数据

func (*StoreClient) MultiDelete

func (s *StoreClient) MultiDelete(identity interface{}, typ []string, id []int64, reply rpc.ReplyCB) error

删除一条记录,identity为返回的标识符,typ查询的数据类型,待删除对象的id

func (*StoreClient) MultiInsert

func (s *StoreClient) MultiInsert(identity interface{}, reply rpc.ReplyCB, typ []string, object []interface{}) error

批量插入,identity为返回的标识符,typ查询的object数据类型集合,object待插入的数据集合

func (*StoreClient) MultiUpdate

func (s *StoreClient) MultiUpdate(identity interface{}, typ []string, object []interface{}, reply rpc.ReplyCB) error

批量更新,identity为返回的标识符,typ查询的object数据类型集合,object待插入的数据集合

func (*StoreClient) OnDatabaseReady

func (s *StoreClient) OnDatabaseReady(evt string, args ...interface{})

func (*StoreClient) Query

func (s *StoreClient) Query(identity interface{}, sql string, args []interface{}, reply rpc.ReplyCB) error

原生sql查询,identity为返回的标识符,sql为查询语句,args是参数

func (*StoreClient) Update

func (s *StoreClient) Update(identity interface{}, typ string, cols []string, condition map[string]interface{}, object interface{}, reply rpc.ReplyCB) error

更新一条记录,identity为返回的标识符,typ查询的数据类型,cols更新的列,condition为条件{column:value},object待插入的数据

type StoreModule

type StoreModule struct {
	service.Module
	// contains filtered or unexported fields
}

func New

func New() *StoreModule

func (*StoreModule) Client

func (m *StoreModule) Client() *StoreClient

func (*StoreModule) CreateDBObj

func (m *StoreModule) CreateDBObj(name string) interface{}

func (*StoreModule) Extend

func (m *StoreModule) Extend(name string, ext Extension)

扩充接口

func (*StoreModule) Init

func (m *StoreModule) Init() bool

func (*StoreModule) Name

func (m *StoreModule) Name() string

func (*StoreModule) Register

func (m *StoreModule) Register(name string, obj interface{}, objslice interface{}) error

func (*StoreModule) SetMode

func (m *StoreModule) SetMode(mode int)

SetMode 设置工作模式

func (*StoreModule) Shut

func (m *StoreModule) Shut()

Shut 模块关闭

func (*StoreModule) Sql

func (m *StoreModule) Sql() *Sql

func (*StoreModule) Start

func (m *StoreModule) Start()

Jump to

Keyboard shortcuts

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