Discover Packages
github.com/itzmeanjan/pub0sub
ops
package
Version:
v0.1.0
Opens a new window with list of versions in this module.
Published: May 18, 2021
License: CC0-1.0
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 3
Opens a new window with list of known importers.
Documentation
Documentation
¶
View Source
var (
ErrTerminateConnection = errors .New ("unsupported opcode, begin connection tear down")
ErrConnectionTerminated = errors .New ("connection already teared down")
ErrEmptyTopicSet = errors .New ("topic list is empty")
)
type AddSubscriptionRequest struct {
Id uint64
Topics []string
}
AddSubscriptionRequest - After a subcriber is registered i.e. has been allocated
one unique subscription id they can subscribe to more topics, that's what's being done here
ReadFrom - Read subscription request back from stream & constructs object
WriteTo - Writes subscription request to stream in recoverable form
CountResponse - Lets publisher/ subscriber know of some sort of count
which has context specific meaning like `how many topics were successfully
subscribed to ?` or `how many subscribers received message ?`
ReadFrom - Recover content back from stream
WriteTo - Write to stream
Publisher to send message in this form
ReadFrom - Reconstructs message back from stream
WriteTo - Writes message to byte stream in recoverable form
NewSubResponse - After sending subscriber registration request
along with topic list of interest, it expects to hear back with
`what's its subcriber id ?` & `how many topics it successfully got subscribed to ?`
ReadFrom - Reads back from stream into structured form
WriteTo - Writes to stream
type NewSubscriptionRequest struct {
Topics []string
}
NewSubscriptionRequest - Subscriber to send new topic subscription request over stream
ReadFrom - Read subscription request back from stream & constructs object
WriteTo - Writes subscription request to stream in recoverable form
const (
UNSUPPORTED OP = iota + 1
PUB_REQ
PUB_RESP
NEW_SUB_REQ
NEW_SUB_RESP
MSG_PUSH
ADD_SUB_REQ
ADD_SUB_RESP
UNSUB_REQ
UNSUB_RESP
)
ReadFrom - Reads operation code from stream & uses
proper handler method for reading messsage, eventually
acts on it
WriteTo - Writes operation type to stream, so that
receiving party can understand intention of message
it's going to read
PushedMessage - Manager to push message to subscriber in this form
as soon as it's ready to push it, after getting notified by HUB
ReadFrom - Subscriber reads received pushed message from byte stream
into structured data
WriteTo - Writes to message binary to byte stream
type UnsubcriptionRequest struct {
Id uint64
Topics []string
}
UnsubcriptionRequest - Client to send topic unsubscription request
in this form
ReadFrom - Read unsubscription request back from stream & constructs object
WriteTo - Subscriber to write topic unsubcription request to stream
Source Files
¶
Click to show internal directories.
Click to hide internal directories.