Documentation
¶
Index ¶
- Constants
- type AMQPService
- func (a *AMQPService) AddObjectHandler(handler ObjectHandler)
- func (a *AMQPService) GetExchangeName(exchnageName string) string
- func (a *AMQPService) GetExchangeType(exchnageType string) string
- func (a *AMQPService) ReceiveObjects() error
- func (a *AMQPService) SendObject(e *EventPayload) error
- func (a *AMQPService) SetExchangeName(exchnageName string)
- func (a *AMQPService) SetExchnageType(exchangeType string)
- type EventPayload
- type ObjectHandler
- type Service
Constants ¶
const ( // CREATE means create new service CREATED = "created" // UPDATE means update existing service UPDATED = "updated" // DELETE means delete existing service DELETED = "deleted" )
Event types
const ( // Event object for microservice-organization ORGANIZATION = "organization" // Event object for schema-management SCHEMA = "schema" // Event object for microservice-resources RESOURCE = "resource" // Event object for microservice-data DATA = "data" )
Object types
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AMQPService ¶
type AMQPService struct {
Channel *rabbitmq.AMQPChannel
ExchnageName string
ExchangeType string
// contains filtered or unexported fields
}
AMQPService holds info for AMQP based implementation
func NewService ¶
func NewService(mqConfig *commonCfg.MQConfig) (*AMQPService, func(), error)
NewService creates notification service for sending and receiving messages on the queue
func (*AMQPService) AddObjectHandler ¶
func (a *AMQPService) AddObjectHandler(handler ObjectHandler)
AddObjectHandler adds new Platform Object Handler. Handlers are called when ReceiveObjects is execute
func (*AMQPService) GetExchangeName ¶
func (a *AMQPService) GetExchangeName(exchnageName string) string
GetExchangeName return the exchange name of notification service
func (*AMQPService) GetExchangeType ¶
func (a *AMQPService) GetExchangeType(exchnageType string) string
GetExchangeType returns the exchange type
func (*AMQPService) ReceiveObjects ¶
func (a *AMQPService) ReceiveObjects() error
ReceiveObjects receives platorm object payload. It calls notification service handlers
func (*AMQPService) SendObject ¶
func (a *AMQPService) SendObject(e *EventPayload) error
SendObject sends an event object for handling platform objects to the queue
func (*AMQPService) SetExchangeName ¶
func (a *AMQPService) SetExchangeName(exchnageName string)
SetExchangeName set the exchange name for the notification service
func (*AMQPService) SetExchnageType ¶
func (a *AMQPService) SetExchnageType(exchangeType string)
SetExchnageType sets the exchnage type
type EventPayload ¶
type EventPayload struct {
// ObjectID is the ID of the object( Organization ID or schema ID or resource ID etc)
ObjectID string `json:"objectID"`
// ObjectType is the type of the object("organization", "schema" etc)
ObjectType string `json:"objectType"`
// Event is one of "CREATE", "UPDATE" or "DELETE
Event string `json:"event"`
// Data holds the additional event data
Data map[string]interface{} `json:"data"`
// ErrorMessages is the actual errors if they happen.
// Event payload in this case is published on error queue along with errors
ErrorMessages []string `json:"errorMessages"`
}
EventPayload describes the event object for handling dynamic services
type ObjectHandler ¶
ObjectHandler receives message from message queue
type Service ¶
type Service interface {
// SendObject sends an event obect to the queue to notify for new object event
SendObject(e *EventPayload) error
// ReceiveObjects receives platform object payload
ReceiveObjects() error
// AddObjectHandler adds new platform object handler
AddObjectHandler(handler ObjectHandler)
// SetExchangeName set the exchange name for the notification service
SetExchangeName(exchnageName string)
// GetExchangeName return the exchange name of notification service
GetExchangeName(queueName string) string
}
Service defines the interface for sending object to the queue