...

Package eiimsgbus

import "EIIMessageBus/eiimsgbus"
Overview
Index

Overview ▾

func ParseJsonConfig

func ParseJsonConfig(jsonBytes []byte) (map[string]interface{}, error)

Helper function for parsing a JSON configuration for the message bus from the given byte blob.

Note: This method automatically takes care of using a JSON decode having set the UseNumber() flag.

func ReadJsonConfig

func ReadJsonConfig(fileName string) (map[string]interface{}, error)

Helper function for reading a JSON configuration for the message bus from a JSON configuration file.

Note: This method automatically takes care of using a JSON decode having set the UseNumber() flag.

type MsgbusClient

Message bus client object

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

func NewMsgbusClient

func NewMsgbusClient(config map[string]interface{}) (*MsgbusClient, error)

Initialize a new message bus context.

func (*MsgbusClient) Close

func (ctx *MsgbusClient) Close()

Close the messaage bus client.

**IMPORTANT NOTE:** After this is called, no other operations using this context will succeed (including methods on publishers, subscribers, etc.).

func (*MsgbusClient) GetService

func (ctx *MsgbusClient) GetService(serviceName string) (*ServiceRequester, error)

func (*MsgbusClient) IsClosed

func (ctx *MsgbusClient) IsClosed() bool

Check if the message bus client has already been destroyed.

func (*MsgbusClient) NewPublisher

func (ctx *MsgbusClient) NewPublisher(topic string) (*Publisher, error)

Create a new publisher on the message bus context.

func (*MsgbusClient) NewService

func (ctx *MsgbusClient) NewService(serviceName string) (*Service, error)

Create a new service to receive requests over and send responses from.

func (*MsgbusClient) NewSubscriber

func (ctx *MsgbusClient) NewSubscriber(topic string) (*Subscriber, error)

Create a new subscriber for the specified topic.

type Publisher

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

func (*Publisher) Close

func (pub *Publisher) Close() error

func (*Publisher) Publish

func (pub *Publisher) Publish(msg interface{}) error

type Service

Service object. This object is not thread-safe.

Since service objects are not safe, all requests and sending of responses must occur in the same thread (i.e. goroutine).

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

func (*Service) Close

func (service *Service) Close()

Close the subscriber

func (*Service) ReceiveRequest

func (service *Service) ReceiveRequest(timeout int) (*types.MsgEnvelope, error)

Receive a request issued to the service.

The timeout parameter determines how the receive call will function. If the timeout is less than 0, then it will block for ever. If it is set 0, then it will return immediately. If the caller wishes there to be a timeout, then the timeout should be specified in milliseconds.

For the no wait and timeout modes, if no message is received then both return values will be nil.

func (*Service) Response

func (service *Service) Response(response interface{}) error

Send a response to a request received by the service.

type ServiceRequester

ServiceRequester object. This object is not thread-safe.

Since service request objects are not safe, all sending of requests and receiving of responses must occur in the same thread (i.e. goroutine).

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

func (*ServiceRequester) Close

func (service *ServiceRequester) Close()

Close the subscriber

func (*ServiceRequester) ReceiveResponse

func (service *ServiceRequester) ReceiveResponse(timeout int) (*types.MsgEnvelope, error)

Receive a response to a previously sent request.

The timeout parameter determines how the receive call will function. If the timeout is less than 0, then it will block for ever. If it is set 0, then it will return immediately. If the caller wishes there to be a timeout, then the timeout should be specified in milliseconds.

For the no wait and timeout modes, if no message is received then both return values will be nil.

func (*ServiceRequester) Request

func (service *ServiceRequester) Request(request interface{}) error

Send a request to the service.

type Subscriber

Subscriber object. This object is not thread-safe.

type Subscriber struct {
    MessageChannel chan *types.MsgEnvelope
    ErrorChannel   chan error
    // contains filtered or unexported fields
}

func (*Subscriber) Close

func (subscriber *Subscriber) Close()

Close the subscriber