Documentation ¶
Overview ¶
TODO : Split broker and Master into two.
Package metre is used to schedule end execute cron jobs in a simplified fashion
Index ¶
- Constants
- func CleanResponseMessage(msg string) (string, error)
- func CreateErrorMsg(err error, id, uid, jobguid string) string
- func SerializeMsg(msgObj *MetreMessage) string
- func StartBroker(dealerUri string, routerUri string)
- type Master
- type Metre
- type MetreMessage
- type SchInput
- type Slave
- type Task
Constants ¶
View Source
const ( Status msgType = iota Request Debug Error )
View Source
const DealerPort string = "5556" // Default port for queue
View Source
const LocalHost string = "tcp://127.0.0.1" // Default host for cache and queue
View Source
const RouterPort string = "5555" // Default port for queue
Variables ¶
This section is empty.
Functions ¶
func CleanResponseMessage ¶
func CreateErrorMsg ¶
func SerializeMsg ¶
func SerializeMsg(msgObj *MetreMessage) string
func StartBroker ¶
Types ¶
type Master ¶
type Master struct { Cron cron.Cron SchInpChan chan *SchInput TaskMap map[string]*Task // contains filtered or unexported fields }
Master is the representation of a master server. It can register tasks which gets scheduled periodically. Multiple master instances can connect to a broker. The schParallel defines the number of request connections to the broker.
func (*Master) ScheduleFromId ¶
type MetreMessage ¶
type MetreMessage struct { // JobGUID is the low-level unique id that metre will track between master and slaves. JobGUID string `json:"job_guid"` // UID is the application level unique id that the app can track for it's own purpose. UID string `json:"uid"` MessageType msgType `json:"msg_type"` TaskId string `json:"task_id"` Message string `json:"message"` }
The set of messages metre passes between master and slave.
func CreateMsg ¶
func CreateMsg(mt msgType, id, uid, jobguid, msg string) *MetreMessage
func ParseMessage ¶
func ParseMessage(msg string) (*MetreMessage, error)
type SchInput ¶
func NewScheduleInput ¶
type Slave ¶
Slave has a set of workers which listens for request's Each of these workers, work in parallel, thanks to ZMQ
func (*Slave) GetResponse ¶
func (*Slave) StartSlave ¶
func (s *Slave) StartSlave()
type Task ¶
type Task struct { sync.Mutex MessageChannel chan string StartTime time.Time ID string // Type Type of task (user as class prefix in cache) Interval string // Schedule String in cron notation Schedule func(*Master) error Process func(*MetreMessage) (string, error) }
func (*Task) Evaluate ¶
func (t *Task) Evaluate(msg *MetreMessage)
func (*Task) SendMessage ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.