Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( UnSupportCoderType = errors.New("unkown jsonpn coder type") InvalidConfigPath = errors.New("invalid service config path") )
Functions ¶
func RegisterToFactory ¶
func RegisterToFactory(name string, factoryFunc FactoryFunc)
RegisterToFactory 注册JsonPbCoder的类型
Types ¶
type FactoryFunc ¶ added in v0.5.20
type FactoryFunc func(...Option) (IJsonPbCoder, error)
FactoryFunc 工厂函数原型
type IJsonPbCoder ¶
type IJsonPbCoder interface { //Init 初始化coder 模块 Init(...Option) error //Restart 重启整个模块,会重新加载配置 Restart() error //JsonStrToProtoBuffer json 请求字符串转化为pb 序列化字节流 JsonStrToProtoBuffer(string, string, string) ([]byte, error) //JsonStrToProtoBufferWithContext json 请求字符串转化为pb 序列化字节流, 附带填充context信息 JsonStrToProtoBufferWithContext(string, string, string, string) ([]byte, error) //ProtoBufferToJson pb 字节流 转化为 json 格式 ProtoBufferToJson(string, string, []byte) (string, error) //UnInit 卸载coder 模块 UnInit() error }
IJsonPbCoder json string to pb 的编码器
func MakeJsonPbWithType ¶
func MakeJsonPbWithType(name string, opts ...Option) (IJsonPbCoder, error)
MakeJsonPbWithType 根据类型创建jsonpb转码器
type Option ¶
type Option func(options *Options)
Option 设置函数
func WithConfigPath ¶
func WithPbVersion ¶ added in v0.5.7
Click to show internal directories.
Click to hide internal directories.