Documentation ¶
Overview ¶
Package protocol is a generated protocol buffer package.
It is generated from these files:
message.proto session.proto sync.proto
It has these top-level messages:
Message LoginReq LoginRsp OfflineNotify StatusNotify SyncNotify SyncReq SyncRsp
Index ¶
- Constants
- Variables
- func NewProtobufDecoder() goetty.Decoder
- func NewProtobufEncoder() goetty.Encoder
- type BaseBiz
- type BaseCMD
- type Equiment
- type LoginReq
- type LoginRsp
- type Message
- func (*Message) Descriptor() ([]byte, []int)
- func (m *Message) GetBiz() int32
- func (m *Message) GetCliSeqId() int32
- func (m *Message) GetCliVersion() int32
- func (m *Message) GetCmd() int32
- func (m *Message) GetData() []byte
- func (m *Message) GetMsgId() string
- func (m *Message) GetProduct() int32
- func (m *Message) GetProtocolVersion() int32
- func (m *Message) GetSessionId() string
- func (*Message) ProtoMessage()
- func (m *Message) Reset()
- func (m *Message) String() string
- type OfflineNotify
- type Pool
- type ProtobufDecoder
- type ProtobufEncoder
- type RedisSyncProtocol
- func (self RedisSyncProtocol) Clear(id string) error
- func (self RedisSyncProtocol) Create(id string) error
- func (self RedisSyncProtocol) Get(id string, count int64, offset int64) ([]*Message, int64, error)
- func (self RedisSyncProtocol) Rename(oldId string, newId string) error
- func (self RedisSyncProtocol) Set(id string, msgs ...*Message) (int64, error)
- func (self RedisSyncProtocol) SetTimeout(id string, seconds int) error
- type RouterCMD
- type Status
- type StatusNotify
- type SyncNotify
- type SyncProtocol
- type SyncReq
- type SyncRsp
Constants ¶
View Source
const ( SYNC_ID_PREFIX = "sync_id_" SYNC_PREFIX = "sync_" SYNC_HEAD_OFFSET_PREFIX = "sync_head_offset_" )
View Source
const Default_LoginRsp_Code int32 = 0
View Source
const (
KEY_TTL = 3600 * 24 * 365 // one year
)
Variables ¶
View Source
var ( POOL = NewPool() DECODER = goetty.NewIntLengthFieldBasedDecoder(NewProtobufDecoder()) ENCODER = NewProtobufEncoder() )
View Source
var BaseBiz_name = map[int32]string{
1: "SESSION",
2: "FRIENDS",
3: "MESSAGE",
4: "GROUP",
}
View Source
var BaseBiz_value = map[string]int32{
"SESSION": 1,
"FRIENDS": 2,
"MESSAGE": 3,
"GROUP": 4,
}
View Source
var BaseCMD_name = map[int32]string{
100: "ACK",
101: "NTY_SYNC",
102: "REQ_SYNC",
103: "RSP_SYNC",
200: "REQ_LOGIN",
201: "RSP_LOGIN",
}
View Source
var BaseCMD_value = map[string]int32{
"ACK": 100,
"NTY_SYNC": 101,
"REQ_SYNC": 102,
"RSP_SYNC": 103,
"REQ_LOGIN": 200,
"RSP_LOGIN": 201,
}
View Source
var Equiment_name = map[int32]string{
1: "PC",
2: "WEB",
3: "ANDROID",
4: "IOS",
}
View Source
var Equiment_value = map[string]int32{
"PC": 1,
"WEB": 2,
"ANDROID": 3,
"IOS": 4,
}
View Source
var RouterCMD_name = map[int32]string{
0: "SESSION_CLOSED",
1: "SESSION_CLOSED_COMPLETE",
10: "CHANGE_ROUTER",
99: "HEATBEAT",
}
View Source
var RouterCMD_value = map[string]int32{
"SESSION_CLOSED": 0,
"SESSION_CLOSED_COMPLETE": 1,
"CHANGE_ROUTER": 10,
"HEATBEAT": 99,
}
View Source
var Status_name = map[int32]string{
1: "ONLINE",
2: "OFFLINE",
}
View Source
var Status_value = map[string]int32{
"ONLINE": 1,
"OFFLINE": 2,
}
Functions ¶
func NewProtobufDecoder ¶
func NewProtobufEncoder ¶
Types ¶
type Equiment ¶
type Equiment int32
func (Equiment) EnumDescriptor ¶
func (*Equiment) UnmarshalJSON ¶
type LoginReq ¶
type LoginReq struct { Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` Password *string `protobuf:"bytes,2,req,name=password" json:"password,omitempty"` Equiment *Equiment `protobuf:"varint,3,req,name=equiment,enum=protocol.Equiment" json:"equiment,omitempty"` Status *Status `protobuf:"varint,4,opt,name=status,enum=protocol.Status,def=1" json:"status,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*LoginReq) Descriptor ¶
func (*LoginReq) GetEquiment ¶
func (*LoginReq) GetPassword ¶
func (*LoginReq) ProtoMessage ¶
func (*LoginReq) ProtoMessage()
type LoginRsp ¶
type LoginRsp struct { Code *int32 `protobuf:"varint,1,req,name=code,def=0" json:"code,omitempty"` Token *string `protobuf:"bytes,2,opt,name=token" json:"token,omitempty"` Timeout *int64 `protobuf:"varint,3,opt,name=timeout" json:"timeout,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*LoginRsp) Descriptor ¶
func (*LoginRsp) GetTimeout ¶
func (*LoginRsp) ProtoMessage ¶
func (*LoginRsp) ProtoMessage()
type Message ¶
type Message struct { Cmd *int32 `protobuf:"varint,1,req,name=cmd" json:"cmd,omitempty"` Biz *int32 `protobuf:"varint,2,opt,name=biz" json:"biz,omitempty"` Product *int32 `protobuf:"varint,3,opt,name=product" json:"product,omitempty"` CliVersion *int32 `protobuf:"varint,4,opt,name=cliVersion" json:"cliVersion,omitempty"` CliSeqId *int32 `protobuf:"varint,5,opt,name=cliSeqId" json:"cliSeqId,omitempty"` ProtocolVersion *int32 `protobuf:"varint,6,opt,name=protocolVersion" json:"protocolVersion,omitempty"` SessionId *string `protobuf:"bytes,7,opt,name=sessionId" json:"sessionId,omitempty"` MsgId *string `protobuf:"bytes,8,opt,name=msgId" json:"msgId,omitempty"` Data []byte `protobuf:"bytes,9,opt,name=data" json:"data,omitempty"` XXX_unrecognized []byte `json:"-"` }
router -> backend, exclude RouterCMD
func (*Message) Descriptor ¶
func (*Message) GetCliSeqId ¶
func (*Message) GetCliVersion ¶
func (*Message) GetProduct ¶
func (*Message) GetProtocolVersion ¶
func (*Message) GetSessionId ¶
func (*Message) ProtoMessage ¶
func (*Message) ProtoMessage()
type OfflineNotify ¶
type OfflineNotify struct { Code *int32 `protobuf:"varint,1,req,name=code" json:"code,omitempty"` XXX_unrecognized []byte `json:"-"` }
backend -> client when client received this message, the session is closed by backend, client should be disconnect the connection
func (*OfflineNotify) Descriptor ¶
func (*OfflineNotify) Descriptor() ([]byte, []int)
func (*OfflineNotify) GetCode ¶
func (m *OfflineNotify) GetCode() int32
func (*OfflineNotify) ProtoMessage ¶
func (*OfflineNotify) ProtoMessage()
func (*OfflineNotify) Reset ¶
func (m *OfflineNotify) Reset()
func (*OfflineNotify) String ¶
func (m *OfflineNotify) String() string
type ProtobufDecoder ¶
type ProtobufDecoder struct { }
type ProtobufEncoder ¶
type ProtobufEncoder struct { }
type RedisSyncProtocol ¶
type RedisSyncProtocol struct {
// contains filtered or unexported fields
}
func (RedisSyncProtocol) Clear ¶
func (self RedisSyncProtocol) Clear(id string) error
func (RedisSyncProtocol) Create ¶
func (self RedisSyncProtocol) Create(id string) error
func (RedisSyncProtocol) Rename ¶
func (self RedisSyncProtocol) Rename(oldId string, newId string) error
func (RedisSyncProtocol) Set ¶
func (self RedisSyncProtocol) Set(id string, msgs ...*Message) (int64, error)
func (RedisSyncProtocol) SetTimeout ¶
func (self RedisSyncProtocol) SetTimeout(id string, seconds int) error
type RouterCMD ¶
type RouterCMD int32
func (RouterCMD) EnumDescriptor ¶
func (*RouterCMD) UnmarshalJSON ¶
type Status ¶
type Status int32
const Default_LoginReq_Status Status = Status_ONLINE
func (Status) EnumDescriptor ¶
func (*Status) UnmarshalJSON ¶
type StatusNotify ¶
type StatusNotify struct { UserId *int32 `protobuf:"varint,1,req,name=userId" json:"userId,omitempty"` Equiment *Equiment `protobuf:"varint,2,req,name=equiment,enum=protocol.Equiment" json:"equiment,omitempty"` Status *Status `protobuf:"varint,3,req,name=status,enum=protocol.Status" json:"status,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*StatusNotify) Descriptor ¶
func (*StatusNotify) Descriptor() ([]byte, []int)
func (*StatusNotify) GetEquiment ¶
func (m *StatusNotify) GetEquiment() Equiment
func (*StatusNotify) GetStatus ¶
func (m *StatusNotify) GetStatus() Status
func (*StatusNotify) GetUserId ¶
func (m *StatusNotify) GetUserId() int32
func (*StatusNotify) ProtoMessage ¶
func (*StatusNotify) ProtoMessage()
func (*StatusNotify) Reset ¶
func (m *StatusNotify) Reset()
func (*StatusNotify) String ¶
func (m *StatusNotify) String() string
type SyncNotify ¶
type SyncNotify struct { Offset *int64 `protobuf:"varint,1,req,name=offset" json:"offset,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*SyncNotify) Descriptor ¶
func (*SyncNotify) Descriptor() ([]byte, []int)
func (*SyncNotify) GetOffset ¶
func (m *SyncNotify) GetOffset() int64
func (*SyncNotify) ProtoMessage ¶
func (*SyncNotify) ProtoMessage()
func (*SyncNotify) Reset ¶
func (m *SyncNotify) Reset()
func (*SyncNotify) String ¶
func (m *SyncNotify) String() string
type SyncProtocol ¶
type SyncProtocol interface { Clear(id string) error Create(id string) error Rename(oldId string, newId string) error SetTimeout(id string, seconds int) error Set(id string, msgs ...*Message) (maxOffset int64, err error) Get(id string, count int64, offset int64) (messages []*Message, readedOffset int64, err error) }
sync protocol server -> client sync_notify client -> server sync_req server -> client sync_rsp server side use queue store messages, client use offset to get message. server received a sync message, delete messages which index is less than the client offset, and return the messages which index between offset+1 and offset+count
func NewRedisSyncProtocol ¶
func NewRedisSyncProtocol(pool *redis.Pool) SyncProtocol
type SyncReq ¶
type SyncReq struct { Offset *int64 `protobuf:"varint,1,req,name=offset" json:"offset,omitempty"` Count *int32 `protobuf:"varint,2,opt,name=count" json:"count,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*SyncReq) Descriptor ¶
func (*SyncReq) ProtoMessage ¶
func (*SyncReq) ProtoMessage()
type SyncRsp ¶
type SyncRsp struct { Offset *int64 `protobuf:"varint,1,req,name=offset" json:"offset,omitempty"` Messages []*Message `protobuf:"bytes,2,rep,name=messages" json:"messages,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*SyncRsp) Descriptor ¶
func (*SyncRsp) GetMessages ¶
func (*SyncRsp) ProtoMessage ¶
func (*SyncRsp) ProtoMessage()
Click to show internal directories.
Click to hide internal directories.