Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // Connect . Connect() error // Disconnect . Disconnect() error // Publish 消息发布 Publish(topic string, v interface{}, opts ...PublishOption) error // Subscribe 消息订阅 Subscribe(topic string, handler Handler, otps ...SubscribeOption) // Type . Type() Type }
Client .
type Event ¶
type Event interface { // Topic . Topic() string // Body return bytes of Message.Data Body() []byte // Unmarshal unmarshal for Message.Data. must be a pointer Unmarshal(v interface{}) error }
Event .
type Message ¶
type Message struct { // ID topic 唯一标识符 16字节 ID uuid.UUID `json:"id"` // Topic subject Topic string `json:"topic"` // Producer . Producer string `json:"producer"` // CreatedAt 创建时间 CreatedAt string `json:"created_at"` // ContentType 编码类型 application/json | application/proto ContentType content.Type `json:"content_type"` // Data . Data interface{} `json:"data"` }
Message .
type Options ¶
type Options struct { // Address adress Address string // ReconnectTime 重连等待时间。单位:秒 ReconnectTime time.Duration // Debug print message Debug bool }
Options .
type PublishOption ¶
type PublishOption func(o *PublishOptions)
func PublishJson ¶
func PublishJson(opts ...func(o *codec.MarshalOptions)) PublishOption
PublishJson .
func PublishProto ¶
func PublishProto(opts ...func(o *codec.MarshalOptions)) PublishOption
PublishProto .
type PublishOptions ¶
type PublishOptions struct { // Codec 序列化方式. default codec.MarshalerType_Json Codec codec.Marshaler }
PublishOptions .
type SubscribeOption ¶
type SubscribeOption func(o *SubscribeOptions)
type SubscribeOptions ¶
type SubscribeOptions struct { // Context ctx Context context.Context // Codec 序列化方式. default codec.MarshalerType_Json Codec codec.Marshaler }
SubscribeOptions .
func DefaultSubscribeOptions ¶
func DefaultSubscribeOptions() *SubscribeOptions
DefaultSubscribeOptions .
Click to show internal directories.
Click to hide internal directories.