mqclient

package
v0.0.0-...-532f06c Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeliveryTypeAtMostOnce  = "at_most_once"
	DeliveryTypeAtLeastOnce = "at_least_once"
	DeliveryTypeExactlyOnce = "exactly_once"
)
View Source
const (
	OperationNewTopic          = "new_topic"
	OperationNewQueue          = "new_queue"
	OperationBind              = "bind"
	OperationNewPublishGroup   = "new_publish_group"
	OperationNewSubscribeGroup = "new_subscribe_group"
	OperationNewMessage        = "new_message"
	OperationAckMessage        = "ack_message"
	OperationNewMessageCommit  = "new_message_commit"
	OperationReleaseMessage    = "release_message"
)
View Source
const (
	IncomingOperationMessage          = "message"
	IncomingOperationMessageReleasing = "message_releasing"
	IncomingOperationReply            = "reply"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AckMessage

type AckMessage struct {
	SubscribeGroup string       `json:"subscribe_group"`
	Queue          string       `json:"queue"`
	MessageId      idgen.IdType `json:"message_id"`

	ReplyId         string `json:"reply_id"`
	ReplyIdentifier string `json:"reply_identifier"`
	Payload         []byte `json:"payload"`
}

type BindRequest

type BindRequest struct {
	Topic      string `json:"topic"`
	Queue      string `json:"queue"`
	BindingKey string `json:"binding_key"`
}

type Client

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

func NewClient

func NewClient(addrs ...string) (*Client, error)

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) (*Session, error)

func (*Client) SetDebug

func (c *Client) SetDebug(debug bool)

type Codec

type Codec interface {
	ReqMarshal(req interface{}) ([]byte, error)
	ReqUnmarshal(data []byte) (interface{}, error)
	ResMarshal(req interface{}) ([]byte, error)
	ResUnmarshal(data []byte) (interface{}, error)
}

type DeliveryType

type DeliveryType int
const (
	AtMostOnce  DeliveryType = 1
	AtLeastOnce DeliveryType = 2
	ExactlyOnce DeliveryType = 3
)

type Message

type Message struct {
	Topic          string       `json:"topic"`
	Queue          string       `json:"queue"`
	BindingKey     string       `json:"binding_key"`
	SubscribeGroup string       `json:"subscribe_group"`
	MessageId      idgen.IdType `json:"message_id"`
	Payload        []byte       `json:"payload"`

	ReplyId         string `json:"reply_id"`
	ReplyIdentifier string `json:"reply_identifier"`
	// contains filtered or unexported fields
}

type MessageDesc

type MessageDesc struct {
	MessageIdList []MessageId `json:"message_id_list"`
	Topic         string      `json:"topic"`
	BindingKey    string      `json:"binding_key"`
	PublishGroup  string      `json:"publish_group"`
}

type MessageId

type MessageId struct {
	MsgId idgen.IdType `json:"msg_id"`
	OutId idgen.IdType `json:"out_id"`
}

type MessageReleasing

type MessageReleasing struct {
	Topic          string       `json:"topic"`
	Queue          string       `json:"queue"`
	BindingKey     string       `json:"binding_key"`
	SubscribeGroup string       `json:"subscribe_group"`
	MessageId      idgen.IdType `json:"message_id"`

	ReplyId         string `json:"reply_id"`
	ReplyIdentifier string `json:"reply_identifier"`
	// contains filtered or unexported fields
}

type NewMessageRequest

type NewMessageRequest struct {
	Topic        string `json:"topic"`
	PublishGroup string `json:"publish_group"`
	BindingKey   string `json:"binding_key"`
	RpcMeta      *struct {
		ReplyIdentifier string `json:"reply_identifier"`
	} `json:"rpc_meta"`

	Payload []byte `json:"payload"`
}

type NewMessageRes

type NewMessageRes struct {
	MessageIdList []MessageId `json:"message_id_list"`
	Topic         string      `json:"topic"`
	BindingKey    string      `json:"binding_key"`
}

type NewPublishGroupRequest

type NewPublishGroupRequest struct {
	Topic        string `json:"topic"`
	PublishGroup string `json:"publish_group"`
}

type NewQueueRequest

type NewQueueRequest struct {
	Queue             string `json:"queue"`
	DeliveryLevelType string `json:"delivery_level_type"`
}

type NewSubscribeGroupRequest

type NewSubscribeGroupRequest struct {
	Queue          string `json:"queue"`
	SubscribeGroup string `json:"subscribe_group"`
}

type NewTopicRequest

type NewTopicRequest struct {
	Topic             string `json:"topic"`
	DeliveryLevelType string `json:"delivery_level_type"`
}

type PublishGroup

type PublishGroup interface {
	// Publish for publishing message in at most once & at least once modes
	Publish(payload []byte, bindingKey string) (*MessageDesc, error)
	// CommitPublish for committing message at delivery level type of exactly-once
	CommitPublish(desc *MessageDesc) error
}

type PublishGroupRes

type PublishGroupRes struct {
	PublishGroup string `json:"publish_group"`
}

type QueueOption

type QueueOption struct {
	DeliveryLevelType DeliveryType
}

type ReleaseMessage

type ReleaseMessage struct {
	SubscribeGroup string       `json:"subscribe_group"`
	Queue          string       `json:"queue"`
	MessageId      idgen.IdType `json:"message_id"`

	ReplyId         string `json:"reply_id"`
	ReplyIdentifier string `json:"reply_identifier"`
	Payload         []byte `json:"payload"`
}

type Reply

type Reply struct {
	ReplyId         idgen.IdType `json:"reply_id"`
	ReplyIdentifier string       `json:"reply_identifier"`
	Payload         []byte       `json:"payload"`
}

type RpcHandler

type RpcHandler interface {
	Handle(req interface{}) (interface{}, error)
}

type RpcStub

type RpcStub interface {
	Call(req interface{}) (interface{}, error)
}

type ServerSideIncoming

type ServerSideIncoming struct {
	Status    string `json:"status"`
	Info      string `json:"info"`
	RequestId string `json:"request_id"`

	PublishGroupResponse   *PublishGroupRes   `json:"publish_group_res,omitempty"`
	SubscribeGroupResponse *SubscribeGroupRes `json:"subscribe_group_res,omitempty"`

	NewMessageResponse *NewMessageRes `json:"new_message,omitempty"`

	IncomingOperation *string           `json:"operation,omitempty"`
	Message           *Message          `json:"message,omitempty"`
	MessageReleasing  *MessageReleasing `json:"message_releasing,omitempty"`
	Reply             *Reply            `json:"reply,omitempty"`
}

type Session

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

func (*Session) BindTopicAndQueue

func (c *Session) BindTopicAndQueue(topic, queue, bindingKey string) error

func (*Session) Close

func (c *Session) Close(ctx context.Context) error

func (*Session) CreatePublishGroup

func (c *Session) CreatePublishGroup(publishGroupName, topic string) (PublishGroup, error)

func (*Session) CreateQueue

func (c *Session) CreateQueue(queue string, queueOption QueueOption) error

func (*Session) CreateRpcStub

func (c *Session) CreateRpcStub(methodTopic, bindingKey, publishGroup string, encoder Codec) RpcStub

func (*Session) CreateSubscribeGroup

func (c *Session) CreateSubscribeGroup(subscribeGroup, queue string, newSub Subscribe) error

CreateSubscribeGroup bind the subscribeGroup to the queue and create/reuse subscribe callback Note: for the same subscribeGroup, only the earliest subscribe will be registered

func (*Session) CreateTopic

func (c *Session) CreateTopic(topic string, topicOption TopicOption) error

func (*Session) RpcHandle

func (c *Session) RpcHandle(serviceQueue, subscribeGroup string, encoder Codec, h RpcHandler) error

type SimpleRpcHandler

type SimpleRpcHandler struct {
	H func(req interface{}) (interface{}, error)
}

func (*SimpleRpcHandler) Handle

func (s *SimpleRpcHandler) Handle(req interface{}) (interface{}, error)

type Subscribe

type Subscribe interface {
	OnMessage(message *Message, sg SubscribeGroup) error
	OnReleasing(messageMeta *MessageReleasing, sg SubscribeGroup) error
}

type SubscribeGroup

type SubscribeGroup interface {
	Commit(message *Message) error
	Release(messageMeta *MessageReleasing) error
}

type SubscribeGroupRes

type SubscribeGroupRes struct {
	SubscribeGroup string `json:"subscribe_group"`
}

type ToServerSidePacket

type ToServerSidePacket struct {
	Operation string `json:"operation"`
	RequestId string `json:"request_id"`

	NewTopic                 *NewTopicRequest          `json:"new_topic,omitempty"`
	NewQueue                 *NewQueueRequest          `json:"new_queue,omitempty"`
	NewBinding               *BindRequest              `json:"new_binding,omitempty"`
	NewPublishGroupRequest   *NewPublishGroupRequest   `json:"new_publish_group,omitempty"`
	NewSubscribeGroupRequest *NewSubscribeGroupRequest `json:"new_subscribe_group,omitempty"`
	NewMessageRequest        *NewMessageRequest        `json:"new_message,omitempty"`
	NewAckMessage            *AckMessage               `json:"ack_message,omitempty"`
	NewMessageCommitRequest  *MessageDesc              `json:"new_message_commit,omitempty"`
	NewReleaseMessage        *ReleaseMessage           `json:"release_message,omitempty"`
}

type TopicOption

type TopicOption struct {
	DeliveryLevelType DeliveryType
}

Jump to

Keyboard shortcuts

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