README ¶
Go Service Bus (GSB)
Vision
- More impact, More quickly, Less code.
Principles
- Keep it Simple
- You aren't gonna need it
- Design for Evolution
- Least Astonishment
- Avoid Premature Optimisation
Front of Mind
- What are you doing
- What can go wrong
Rules
- Anything that fails during startup / initialisation should fail immediatley with descriptive STDOUT.
- Anything that fails during execution should return an error and be processed by the system, to allow continuous operation.
- Handlers must implement Handler interface
- Handlers can optionally implement an Init() method, with optional return error.
- All user space code execution is initiated by receiving a message.
Guidelines
- All external resources are initialised and validated on start up, then provided on execution as Application Resources.
Rationale
-
Try to raise the level of infrastructure.
-
The infrastructure,
- takes care of starting, committing and rolling back transactions.
- runs all code within the context of a message.
- provides automatic retry if the code errors
- moves failed messages to the error queue
Description
The backbone of GSB is a message queue.
All work is initiated by pulling messages from this message queue.
If all external dependencies, eg, queues, databases, etc are provided as Application Resources, gsb will manage all transactions, meaning the message then provides a transaction boundary.
In this model, a number of options present when errors occur while processing a message. One, they can be retried. For example, their could be a network glitch which has corrected itself by the time the message is retried. Two, for persistent errors, the message can be moved to error queue. For example, a database may be down. In this case, the database can be restarted, and the message sent back for processing.
Variables
- NAME
- RETRIES
- ERROR_Q
- AUDIT_Q
- MQ
- GSB_
- GSBMON_
- VERBOSE
Backbone Message Queue
MQ=type://[username:password@]host/queue_name
- beanstalk
- sqs
- inmemq
Application Resources
GSB_[name]=type://[username:password@]host/path
All external resources are initialised and validated on start up, then provided on execution.
- DynamoDb
- dynamodb
- FileSystem
- s3
- fs
- KeyValue
- dir
- redis
- Queue
- beanstalk
- sqs
- inmemq
AWS Specific
- AWS_ENDPOINT
- AWS_REGION
Monitors
GSBMON_[name]=type://[username:password@]host/path
A monitor will keep checking the end point for incoming messages. If found, it pull the message, wrap it in an envelope, and post it to the backbone mq for processing. The name of the message will be the name portion indicated in the URI above.
- dir
- queue
COMMANDS
To enable the ability to configure the running system, gsb will process commands coming in via the backbone MQ,
- GSB_VERBOSE_ON
- GSB_VERBOSE_OFF
- GSB_AUDIT_ON
- GSB_AUDIT_OFF
References
Documentation ¶
Index ¶
- func ResetMqInMemory()
- type Bus
- type Handler
- type Host
- type MonitorData
- type MqInMemory
- func (mq *MqInMemory) Begin() error
- func (mq *MqInMemory) Commit() error
- func (mq *MqInMemory) Init() error
- func (mq *MqInMemory) Move(fromS string, toS string)
- func (mq *MqInMemory) Name() string
- func (mq *MqInMemory) Retrieve() (*string, error)
- func (mq *MqInMemory) Rollback() error
- func (mq *MqInMemory) Send(payload string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Host ¶
type Host struct { Name string Mq mq MqURL *url.URL LocalSendQ appres.Queue AuditQ appres.Queue ErrorQ appres.Queue Handler map[string]*handlerWrapper // contains filtered or unexported fields }
Host is the root of GSB
func (*Host) AddHandler ¶
AddHandler allows user space code to Add Handlers to GSB
func (*Host) Send ¶ added in v0.0.21
Send is the channel for user space code to send a message with GSB
func (*Host) SendMessage ¶ added in v0.0.2
SendMessage wraps a message in an envelope and puts it to the passed in queue
type MonitorData ¶ added in v0.0.2
MonitorData is supplied to a monitoring Handler
type MqInMemory ¶
type MqInMemory struct { List []string // contains filtered or unexported fields }
MqInMemory swap in queue for testing
func NewMqInMemory ¶
func NewMqInMemory(url *url.URL) *MqInMemory
NewMqInMemory returns the singleton, creating if necessary
func NewMqInMemoryFromString ¶
func NewMqInMemoryFromString(urlString string) *MqInMemory
NewMqInMemoryFromString adapter for NewMqInMemory
func (*MqInMemory) Move ¶
func (mq *MqInMemory) Move(fromS string, toS string)
Move message to a different queue
func (*MqInMemory) Retrieve ¶
func (mq *MqInMemory) Retrieve() (*string, error)
Retrieve wrapper for InMemory Queue
func (*MqInMemory) Rollback ¶ added in v0.0.24
func (mq *MqInMemory) Rollback() error
Rollback Transaction
func (*MqInMemory) Send ¶
func (mq *MqInMemory) Send(payload string) error
Send wrapper for InMemory Queue