protocol

package
v0.0.0-...-130f5e9 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2018 License: Apache-2.0 Imports: 12 Imported by: 22

Documentation

Index

Constants

View Source
const (
	SUCCESS                    = 0 // 成功
	SYSTEM_ERROR               = 1 // 发生了未捕获异常
	SYSTEM_BUSY                = 2 // 由于线程池拥堵,系统繁忙
	REQUEST_CODE_NOT_SUPPORTED = 3 // 请求代码不支持
	TRANSACTION_FAILED         = 4 // 事务失败,添加db失败
)

RemotingSysResponseCode: xxx Author: yintongqiang Since: 2017/8/16

View Source
const (
	FLUSH_DISK_TIMEOUT            = 10  // Broker 刷盘超时
	SLAVE_NOT_AVAILABLE           = 11  // Broker 同步双写,Slave不可用
	FLUSH_SLAVE_TIMEOUT           = 12  // Broker 同步双写,等待Slave应答超时
	MESSAGE_ILLEGAL               = 13  // Broker 消息非法
	SERVICE_NOT_AVAILABLE         = 14  // Broker, Namesrv 服务不可用,可能是正在关闭或者权限问题
	VERSION_NOT_SUPPORTED         = 15  // Broker, Namesrv 版本号不支持
	NO_PERMISSION                 = 16  // Broker, Namesrv 无权限执行此操作,可能是发、收、或者其他操作
	TOPIC_NOT_EXIST               = 17  // Broker, Topic不存在
	TOPIC_EXIST_ALREADY           = 18  // Broker, Topic已经存在,创建Topic
	PULL_NOT_FOUND                = 19  // Broker 拉消息未找到(请求的Offset等于最大Offset,最大Offset无对应消息)
	PULL_RETRY_IMMEDIATELY        = 20  // Broker 可能被过滤,或者误通知等
	PULL_OFFSET_MOVED             = 21  // Broker 拉消息请求的Offset不合法,太小或太大
	QUERY_NOT_FOUND               = 22  // Broker 查询消息未找到
	SUBSCRIPTION_PARSE_FAILED     = 23  // Broker 订阅关系解析失败
	SUBSCRIPTION_NOT_EXIST        = 24  // Broker 订阅关系不存在
	SUBSCRIPTION_NOT_LATEST       = 25  // Broker 订阅关系不是最新的
	SUBSCRIPTION_GROUP_NOT_EXIST  = 26  // Broker 订阅组不存在
	TRANSACTION_SHOULD_COMMIT     = 200 // producer 事务应该被提交
	TRANSACTION_SHOULD_ROLLBACK   = 201 // producer 事务应该被回滚
	TRANSACTION_STATE_UNKNOW      = 202 // producer 事务状态未知
	TRANSACTION_STATE_GROUP_WRONG = 203 // producer ProducerGroup错误
	NO_BUYER_ID                   = 204 // 单元化消息,需要设置 buyerId
	NOT_IN_CURRENT_UNIT           = 205 // 单元化消息,非本单元消息
	CONSUMER_NOT_ONLINE           = 206 // Consumer不在线
	CONSUME_MSG_TIMEOUT           = 207 // Consumer消费消息超时
)

ResponseCode: xxx Author: tianyuliang Since: 2017/9/7

View Source
const (
	RemotingVersionKey = "smartgo.remoting.version"
)

RemotingCommand 服务器与客户端通过传递RemotingCommand来交互 Author gaoyanlei Since 2017/8/15

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandCustomHeader

type CommandCustomHeader interface {
	CheckFields() error
}

type LanguageCode

type LanguageCode int
const (
	JAVA LanguageCode = iota
	CPP
	DOTNET
	PYTHON
	DELPHI
	ERLANG
	RUBY
	OTHER
	HTTP
	GOLANG
)

func (LanguageCode) ToString

func (languageCode LanguageCode) ToString() string

消费类型枚举 Author: yintongqiang Since: 2017/8/8

type RemotingCommand

type RemotingCommand struct {
	Code         int32               `json:"code"`
	Language     string              `json:"language"`
	Version      int32               `json:"version"`
	Opaque       int32               `json:"opaque"`
	Flag         int32               `json:"flag"`
	Remark       string              `json:"remark"`
	ExtFields    map[string]string   `json:"extFields"` // 请求拓展字段
	CustomHeader CommandCustomHeader `json:"-"`         // 修改字段类型,"CustomHeader"字段不序列化 2017/8/24 Modify by jerrylou, <gunsluo@gmail.com>
	Body         []byte              `json:"-"`         // body字段不会被Encode()并进行网络传输,仅仅在ToString()打印日志内部有序列化处理
}

RemotingCommand remoting command Author: jerrylou, <gunsluo@gmail.com> Since: 2017-08-22

func CreateDefaultResponseCommand

func CreateDefaultResponseCommand(customHeader ...CommandCustomHeader) *RemotingCommand

CreateResponseCommand 只有通信层内部会调用,业务不会调用

func CreateRequestCommand

func CreateRequestCommand(code int32, customHeader ...CommandCustomHeader) *RemotingCommand

CreateRequestCommand 创建客户端请求信息 2017/8/16 Add by yintongqiang

func CreateResponseCommand

func CreateResponseCommand(code int32, remark string) *RemotingCommand

CreateResponseCommand

func DecodeRemotingCommand

func DecodeRemotingCommand(buf *bytes.Buffer) (*RemotingCommand, error)

DecodeRemotingCommand 解析返回RemotingCommand

func (*RemotingCommand) Bytes

func (rc *RemotingCommand) Bytes() []byte

Bytes 实现Serirable接口

func (*RemotingCommand) DecodeCommandCustomHeader

func (rc *RemotingCommand) DecodeCommandCustomHeader(commandCustomHeader CommandCustomHeader) error

func (*RemotingCommand) EncodeHeader

func (rc *RemotingCommand) EncodeHeader() []byte

EncodeHeader 编码头部

func (*RemotingCommand) IsOnewayRPC

func (rc *RemotingCommand) IsOnewayRPC() bool

IsOnewayRPC is oneway rpc, return bool

func (*RemotingCommand) IsResponseType

func (rc *RemotingCommand) IsResponseType() bool

IsResponseType is response type, return bool

func (*RemotingCommand) MarkOnewayRPC

func (rc *RemotingCommand) MarkOnewayRPC()

MarkOnewayRPC mark oneway type

func (*RemotingCommand) MarkResponseType

func (rc *RemotingCommand) MarkResponseType()

MarkResponseType mark response type

func (*RemotingCommand) MarshalJSON

func (j *RemotingCommand) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*RemotingCommand) MarshalJSONBuf

func (j *RemotingCommand) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*RemotingCommand) ToString

func (self *RemotingCommand) ToString() string

ToString 打印RemotingCommand对象数据 Author: tianyuliang Since: 2017/9/6

func (*RemotingCommand) Type

Type return remoting command type

func (*RemotingCommand) UnmarshalJSON

func (j *RemotingCommand) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*RemotingCommand) UnmarshalJSONFFLexer

func (j *RemotingCommand) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type RemotingCommandType

type RemotingCommandType int
const (
	REQUEST_COMMAND  RemotingCommandType = iota // 请求命令
	RESPONSE_COMMAND                            // 响应命令
)

type RemotingSerializable

type RemotingSerializable struct {
}

RemotingSerializable 序列化 Author gaoyanlei Since 2017/8/22

func (*RemotingSerializable) CustomDecode

func (self *RemotingSerializable) CustomDecode(data []byte, v interface{}) error

CustomDecode 反序列化为传入参数v结构体 Author: tianyuliang Since: 2017/9/15

func (*RemotingSerializable) CustomEncode

func (self *RemotingSerializable) CustomEncode(v interface{}) []byte

CustomEncode 默认序列化参数v对应的结构体 Author: tianyuliang Since: 2017/9/15

Jump to

Keyboard shortcuts

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