Пример #1
0
func (b *musterBatch) Fire(notifier muster.Notifier) {
	defer notifier.Done()

	data := make(map[string][]EventType)

	for _, e := range b.Events {
		data[e.Collection] = append(data[e.Collection], e.Event)
	}

	var r interface{}
	_, err := b.Client.sling.Post("events").BodyJSON(data).ReceiveSuccess(&r)

	if err != nil {
		log.Warn(err.Error())
	}

}
Пример #2
0
func (m *musterBatch) Fire(notifier muster.Notifier) {
	defer notifier.Done()
	b := &Batch{
		AccessToken: m.Client.AccessToken,
		AppID:       m.Client.AppID,
		Request:     make([]*Request, len(m.WorkRequests)),
	}
	for i, rr := range m.WorkRequests {
		b.Request[i] = rr.Request
	}
	res, err := BatchDo(m.Client.Client, b)
	for i, rr := range m.WorkRequests {
		if err == nil {
			rr.Response <- &workResponse{Response: res[i]}
		} else {
			rr.Response <- &workResponse{Error: err}
		}
	}
}
Пример #3
0
// Once a Batch is ready, it will be Fired. It must call notifier.Done once the
// batch has been processed.
func (b *batch) Fire(notifier muster.Notifier) {
	defer notifier.Done()
	fmt.Println("Delivery", b.Items)
	os.Stdout.Sync()
}
Пример #4
0
func (b *batch) Fire(notifier muster.Notifier) {
	defer notifier.Done()
	if err := b.fire(); err != nil {
		log.Println(err)
	}
}