Documentation ¶
Overview ¶
EZMQ package which provides simplified APIs for Publisher and Subscriber.
Index ¶
- Constants
- func InitLogger()
- type EZMQAPI
- type EZMQByteData
- type EZMQContentType
- type EZMQErrorCB
- type EZMQErrorCode
- type EZMQMessage
- type EZMQPublisher
- func (pubInstance *EZMQPublisher) GetPort() int
- func (pubInstance *EZMQPublisher) Publish(ezmqMsg EZMQMessage) EZMQErrorCode
- func (pubInstance *EZMQPublisher) PublishOnTopic(topic string, ezmqMsg EZMQMessage) EZMQErrorCode
- func (pubInstance *EZMQPublisher) PublishOnTopicList(topicList List.List, ezmqMsg EZMQMessage) EZMQErrorCode
- func (pubInstance *EZMQPublisher) SetServerPrivateKey(key []byte) EZMQErrorCode
- func (pubInstance *EZMQPublisher) Start() EZMQErrorCode
- func (pubInstance *EZMQPublisher) Stop() EZMQErrorCode
- type EZMQStartCB
- type EZMQStatusCode
- type EZMQStopCB
- type EZMQSubCB
- type EZMQSubTopicCB
- type EZMQSubscriber
- func (subInstance *EZMQSubscriber) GetIP() string
- func (subInstance *EZMQSubscriber) GetPort() int
- func (subInstance *EZMQSubscriber) SetClientKeys(clientPrivateKey []byte, clientPublicKey []byte) EZMQErrorCode
- func (subInstance *EZMQSubscriber) SetServerPublicKey(key []byte) EZMQErrorCode
- func (subInstance *EZMQSubscriber) Start() EZMQErrorCode
- func (subInstance *EZMQSubscriber) Stop() EZMQErrorCode
- func (subInstance *EZMQSubscriber) Subscribe() EZMQErrorCode
- func (subInstance *EZMQSubscriber) SubscribeForTopic(topic string) EZMQErrorCode
- func (subInstance *EZMQSubscriber) SubscribeForTopicList(topicList List.List) EZMQErrorCode
- func (subInstance *EZMQSubscriber) SubscribeWithIPPort(ip string, port int, topic string) EZMQErrorCode
- func (subInstance *EZMQSubscriber) UnSubscribe() EZMQErrorCode
- func (subInstance *EZMQSubscriber) UnSubscribeForTopic(topic string) EZMQErrorCode
- func (subInstance *EZMQSubscriber) UnSubscribeForTopicList(topicList List.List) EZMQErrorCode
- type Event
- func (*Event) Descriptor() ([]byte, []int)
- func (m Event) GetContentType() EZMQContentType
- func (m *Event) GetCreated() int64
- func (m *Event) GetDevice() string
- func (m *Event) GetId() string
- func (m *Event) GetModified() int64
- func (m *Event) GetOrigin() int64
- func (m *Event) GetPushed() int64
- func (m *Event) GetReading() []*Reading
- func (*Event) ProtoMessage()
- func (m *Event) Reset()
- func (m *Event) String() string
- type Reading
- func (*Reading) Descriptor() ([]byte, []int)
- func (m *Reading) GetCreated() int64
- func (m *Reading) GetDevice() string
- func (m *Reading) GetId() string
- func (m *Reading) GetModified() int64
- func (m *Reading) GetName() string
- func (m *Reading) GetOrigin() int64
- func (m *Reading) GetPushed() int64
- func (m *Reading) GetValue() string
- func (*Reading) ProtoMessage()
- func (m *Reading) Reset()
- func (m *Reading) String() string
Constants ¶
const ( EZMQ_CONTENT_TYPE_PROTOBUF = 0 EZMQ_CONTENT_TYPE_BYTEDATA = 1 EZMQ_CONTENT_TYPE_AML = 2 // Not in use as of now EZMQ_CONTENT_TYPE_JSON = 3 // Not in use as of now )
Constants represents EZMQ content types.
const ( EZMQ_OK = 0 EZMQ_ERROR = 1 EZMQ_INVALID_TOPIC = 2 EZMQ_INVALID_CONTENT_TYPE = 3 )
Constants represents EZMQ error codes.
const ( EZMQ_Unknown = 0 EZMQ_Constructed = 1 EZMQ_Initialized = 2 EZMQ_Terminated = 3 )
Constants represents EZMQ Status codes.
const INPROC_PREFIX = "inproc://shutdown-"
const PUB_KEY_LENGTH = 40
Publisher key length
const PUB_TCP_PREFIX = "tcp://*:"
Address Prefix for Publisher.
const SUB_KEY_LENGTH = 40
Subscriber key length
const SUB_TCP_PREFIX = "tcp://"
Address prefix to bind subscriber.
const TOPIC_PATTERN = "^[a-zA-Z0-9-_./]+$"
Regex Pattern for Topic validation.
Variables ¶
This section is empty.
Functions ¶
func InitLogger ¶
func InitLogger()
Types ¶
type EZMQAPI ¶
type EZMQAPI struct {
// contains filtered or unexported fields
}
Structure represents EZMQAPI
func (*EZMQAPI) GetContext ¶
func (*EZMQAPI) GetStatus ¶
func (ezmqInstance *EZMQAPI) GetStatus() EZMQStatusCode
func (*EZMQAPI) Initialize ¶
func (ezmqInstance *EZMQAPI) Initialize() EZMQErrorCode
Initialize required EZMQ components. This API should be called first, before using any EZMQ APIs.
func (*EZMQAPI) Terminate ¶
func (ezmqInstance *EZMQAPI) Terminate() EZMQErrorCode
Perform cleanup of EZMQ components.
type EZMQByteData ¶
type EZMQByteData struct {
ByteData []byte
}
Structure represents EZMQByteData.
func (*EZMQByteData) GetByteData ¶
func (dataInstance *EZMQByteData) GetByteData() []byte
Get byte data
func (EZMQByteData) GetContentType ¶
func (dataInstance EZMQByteData) GetContentType() EZMQContentType
Get Content type
func (*EZMQByteData) SetByteData ¶
func (dataInstance *EZMQByteData) SetByteData(byteData []byte) EZMQErrorCode
set byte data
type EZMQContentType ¶
type EZMQContentType int
type EZMQErrorCB ¶
type EZMQErrorCB func(code EZMQErrorCode)
Error Callback for start/stop of EZMQ publisher. [As of now, Not being used]
type EZMQErrorCode ¶
type EZMQErrorCode int
type EZMQMessage ¶
type EZMQMessage interface {
GetContentType() EZMQContentType
}
Interface for ezmq message.
type EZMQPublisher ¶
type EZMQPublisher struct {
// contains filtered or unexported fields
}
Structure represents EZMQPublisher.
func GetEZMQPublisher ¶
func GetEZMQPublisher(port int, startCallback EZMQStartCB, stopCallback EZMQStopCB, errorCallback EZMQErrorCB) *EZMQPublisher
Constructs EZMQPublisher.
func (*EZMQPublisher) Publish ¶
func (pubInstance *EZMQPublisher) Publish(ezmqMsg EZMQMessage) EZMQErrorCode
Publish events on the socket for subscribers.
func (*EZMQPublisher) PublishOnTopic ¶
func (pubInstance *EZMQPublisher) PublishOnTopic(topic string, ezmqMsg EZMQMessage) EZMQErrorCode
Publish events on a specific topic on socket for subscribers.
Note: (1) Topic name should be as path format. For example:home/livingroom/
(2) Topic name can have letters [a-z, A-z], numerics [0-9] and special characters _ - / and .
func (*EZMQPublisher) PublishOnTopicList ¶
func (pubInstance *EZMQPublisher) PublishOnTopicList(topicList List.List, ezmqMsg EZMQMessage) EZMQErrorCode
Publish an events on list of topics on socket for subscribers. On any of the topic in list, if it failed to publish event it will return EZMQ_ERROR/EZMQ_INVALID_TOPIC.
Note: (1) Topic name should be as path format. For example:home/livingroom/
(2) Topic name can have letters [a-z, A-z], numerics [0-9] and special characters _ - / and .
func (*EZMQPublisher) SetServerPrivateKey ¶
func (pubInstance *EZMQPublisher) SetServerPrivateKey(key []byte) EZMQErrorCode
Set the server private/secret key.
Note: (1) Key should be 40-character string encoded in the Z85 encoding format
(2) This API should be called before start() API.
func (*EZMQPublisher) Start ¶
func (pubInstance *EZMQPublisher) Start() EZMQErrorCode
Starts PUB instance.
func (*EZMQPublisher) Stop ¶
func (pubInstance *EZMQPublisher) Stop() EZMQErrorCode
Stops PUB instance.
type EZMQStartCB ¶
type EZMQStartCB func(code EZMQErrorCode)
Callback to get error code for start of EZMQ publisher. [As of now, Not being used]
type EZMQStatusCode ¶
type EZMQStatusCode int
type EZMQStopCB ¶
type EZMQStopCB func(code EZMQErrorCode)
Callback to get error code for stop of EZMQ publisher. [As of now, Not being used]
type EZMQSubTopicCB ¶
type EZMQSubTopicCB func(topic string, event EZMQMessage)
Callback to get all the subscribed events for a specific topic.
type EZMQSubscriber ¶
type EZMQSubscriber struct {
// contains filtered or unexported fields
}
Structure represents EZMQSubscriber.
func GetEZMQSubscriber ¶
func GetEZMQSubscriber(ip string, port int, subCallback EZMQSubCB, subTopicCallback EZMQSubTopicCB) *EZMQSubscriber
Constructs EZMQSubscriber.
func (*EZMQSubscriber) GetIP ¶
func (subInstance *EZMQSubscriber) GetIP() string
Get Ip of publisher to which subscribed.
func (*EZMQSubscriber) GetPort ¶
func (subInstance *EZMQSubscriber) GetPort() int
Get Port of publisher to which subscribed.
func (*EZMQSubscriber) SetClientKeys ¶
func (subInstance *EZMQSubscriber) SetClientKeys(clientPrivateKey []byte, clientPublicKey []byte) EZMQErrorCode
Set the security keys of client/its own.
Note: (1) Key should be 40-character string encoded in the Z85 encoding format <br>
(2) This API should be called before start() API.
func (*EZMQSubscriber) SetServerPublicKey ¶
func (subInstance *EZMQSubscriber) SetServerPublicKey(key []byte) EZMQErrorCode
Set the server public key.
Note: (1) Key should be 40-character string encoded in the Z85 encoding format <br>
(2) This API should be called before start() API.
(3) If using the following API in secured mode:
SubscribeWithIPPort(ip string, port int, topic string) EZMQErrorCode SetServerPublicKey API needs to be called before that.
func (*EZMQSubscriber) Start ¶
func (subInstance *EZMQSubscriber) Start() EZMQErrorCode
Starts SUB instance.
func (*EZMQSubscriber) Stop ¶
func (subInstance *EZMQSubscriber) Stop() EZMQErrorCode
Stops SUB instance.
func (*EZMQSubscriber) Subscribe ¶
func (subInstance *EZMQSubscriber) Subscribe() EZMQErrorCode
Subscribe for event/messages.
func (*EZMQSubscriber) SubscribeForTopic ¶
func (subInstance *EZMQSubscriber) SubscribeForTopic(topic string) EZMQErrorCode
Subscribe for event/messages on a particular topic.
func (*EZMQSubscriber) SubscribeForTopicList ¶
func (subInstance *EZMQSubscriber) SubscribeForTopicList(topicList List.List) EZMQErrorCode
Subscribe for event/messages on given list of topics. On any of the topic in list, if it failed to subscribe events it will return EZMQ_ERROR/EZMQ_INVALID_TOPIC.
Note: (1) Topic name should be as path format. For example:home/livingroom/
(2) Topic name can have letters [a-z, A-z], numerics [0-9] and special characters _ - / and .
func (*EZMQSubscriber) SubscribeWithIPPort ¶
func (subInstance *EZMQSubscriber) SubscribeWithIPPort(ip string, port int, topic string) EZMQErrorCode
Subscribe for event/messages from given IP:Port on the given topic.
Note: (1) It will be using same Subscriber socket for connecting to given ip:port.
(2) To un-subcribe use un-subscribe API with the same topic.
(3) Topic name should be as path format. For example:home/livingroom/
(4) Topic name can have letters [a-z, A-z], numeric [0-9] and special characters _ - / and .
(5) Topic will be appended with forward slash [/] in case, if application has not appended it.
(6) If using in secured mode: Call setServerPublicKey API with target server public key before calling this API.
func (*EZMQSubscriber) UnSubscribe ¶
func (subInstance *EZMQSubscriber) UnSubscribe() EZMQErrorCode
Un-subscribe all the events from publisher.
func (*EZMQSubscriber) UnSubscribeForTopic ¶
func (subInstance *EZMQSubscriber) UnSubscribeForTopic(topic string) EZMQErrorCode
Un-subscribe specific topic events.
Note: (1) Topic name should be as path format. For example:home/livingroom/
(2) Topic name can have letters [a-z, A-z], numerics [0-9] and special characters _ - / and .
func (*EZMQSubscriber) UnSubscribeForTopicList ¶
func (subInstance *EZMQSubscriber) UnSubscribeForTopicList(topicList List.List) EZMQErrorCode
Un-subscribe event/messages on given list of topics. On any of the topic in list, if it failed to unsubscribe events it will return EZMQ_ERROR/EZMQ_INVALID_TOPIC.
Note: (1) Topic name should be as path format. For example:home/livingroom/ .
(2) Topic name can have letters [a-z, A-z], numerics [0-9] and special characters _ - / and .
type Event ¶
type Event struct { Id *string `protobuf:"bytes,1,req,name=id" json:"id,omitempty"` Created *int64 `protobuf:"varint,2,req,name=created" json:"created,omitempty"` Modified *int64 `protobuf:"varint,3,req,name=modified" json:"modified,omitempty"` Origin *int64 `protobuf:"varint,4,req,name=origin" json:"origin,omitempty"` Pushed *int64 `protobuf:"varint,5,req,name=pushed" json:"pushed,omitempty"` Device *string `protobuf:"bytes,6,req,name=device" json:"device,omitempty"` Reading []*Reading `protobuf:"bytes,7,rep,name=reading" json:"reading,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*Event) Descriptor ¶
func (Event) GetContentType ¶
func (m Event) GetContentType() EZMQContentType
This method is added specifically for ezmq message.
func (*Event) GetCreated ¶
func (*Event) GetModified ¶
func (*Event) GetReading ¶
func (*Event) ProtoMessage ¶
func (*Event) ProtoMessage()
type Reading ¶
type Reading struct { Id *string `protobuf:"bytes,1,req,name=id" json:"id,omitempty"` Created *int64 `protobuf:"varint,2,req,name=created" json:"created,omitempty"` Modified *int64 `protobuf:"varint,3,req,name=modified" json:"modified,omitempty"` Origin *int64 `protobuf:"varint,4,req,name=origin" json:"origin,omitempty"` Pushed *int64 `protobuf:"varint,5,req,name=pushed" json:"pushed,omitempty"` Name *string `protobuf:"bytes,6,req,name=name" json:"name,omitempty"` Value *string `protobuf:"bytes,7,req,name=value" json:"value,omitempty"` Device *string `protobuf:"bytes,8,req,name=device" json:"device,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*Reading) Descriptor ¶
func (*Reading) GetCreated ¶
func (*Reading) GetModified ¶
func (*Reading) ProtoMessage ¶
func (*Reading) ProtoMessage()