An open API service indexing awesome lists of open source software.

https://github.com/codekoala/celeriac.v1

Golang client library for adding support for interacting and monitoring Celery workers, tasks and events.
https://github.com/codekoala/celeriac.v1

Last synced: 5 months ago
JSON representation

Golang client library for adding support for interacting and monitoring Celery workers, tasks and events.

Awesome Lists containing this project

README

          

Celeriac
=======

Golang client library for adding support for interacting and monitoring Celery workers and tasks.

It provides functionality to place tasks on the task queue, as well
as monitor task and worker events.

Dependencies
------------
This library depends upon the following packages:
- github.com/streadway/amqp
- github.com/Sirupsen/logrus
- github.com/nu7hatch/gouuid
- github.com/pquerna/ffjson

Usage
-----
Installation: `go get github.com/svcavallar/celeriac.v1`

This imports a new namespace called `celeriac`

```go
package main

import (
"log"
"os"

"github.com/svcavallar/celeriac.v1"
)

func main() {
taskBrokerURI := "amqp://user:pass@localhost:5672/vhost"

// Connect to RabbitMQ task queue
TaskQueueMgr, err := celeriac.NewTaskQueueMgr(taskBrokerURI)
if err != nil {
log.Printf("Failed to connect to task queue: %v", err)
os.Exit(-1)
}

log.Printf("Service connected to task queue - (URL: %s)", taskBrokerURI)

// Get the task events from the task events channel
for {
select {
default:
ev := <-TaskQueueMgr.Monitor.EventsChannel

if ev != nil {

if x, ok := ev.(*celeriac.WorkerEvent); ok {
log.Printf("Task monitor: Worker event - %s", x.Type)
} else if x, ok := ev.(*celeriac.TaskEvent); ok {
log.Printf("Task monitor: Task event - %s [ID]: %s", x.Type, x.UUID)
}

}
}
}
}
```