Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/svcavallar/celeriac.v1
Golang client library for adding support for interacting and monitoring Celery workers, tasks and events.
https://github.com/svcavallar/celeriac.v1
Last synced: about 2 months ago
JSON representation
Golang client library for adding support for interacting and monitoring Celery workers, tasks and events.
- Host: GitHub
- URL: https://github.com/svcavallar/celeriac.v1
- Owner: svcavallar
- License: mit
- Created: 2015-10-10T07:27:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-26T08:25:15.000Z (about 1 year ago)
- Last Synced: 2024-04-18T12:13:20.237Z (2 months ago)
- Language: Go
- Size: 35.2 KB
- Stars: 72
- Watchers: 3
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Lists
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Search and Analytic Databases)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Search and Analytic Databases)
- awesome-go-extra - celeriac.v1 - 10-10T07:27:33Z|2020-10-16T04:43:47Z| (Distributed Systems / Advanced Console UIs)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Search and Analytic Databases)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Search and Analytic Databases)
- fucking-awesome-go - :octocat: celeriac - A library for adding support for interacting and monitoring Celery workers, tasks and events in Go :star: 14 :fork_and_knife: 2 (Distributed Systems / Advanced Console UIs)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- awesome-go-projects - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Standard CLI)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- awesome-go - celeriac - | - | - | (Distributed Systems / Advanced Console UIs)
- awesome-go - celeriac - A library for adding support for interacting and monitoring Celery workers, tasks and events in Go (Distributed Systems / Advanced Console UIs)
- awesome-go-with-framework - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Search and Analytic Databases)
- awesome-go-cn - celeriac
- awesome-go-stars - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Search and Analytic Databases)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- awesome-go - celeriac - 一个GO语言中运用的增加支持互动和监测芹菜工人,任务和事件。 (<span id="分布式系统-distributed-systems">分布式系统 Distributed Systems</span> / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go. - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- awesome-go-cn - celeriac - 利用 Go 语言对Celery 的 worker,任务,事件进行交互和监控的库 (分布式系统 / 高级控制台界面)
- awesome-go-with-stars - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Search and Analytic Databases)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- repo-1316-awesome-go-cn - celeriac
- repo-1211-awesome-go-cn - celeriac
- awesome-Char - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- awesome-reader - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- awesome-go - celeriac - A library for adding support for interacting and monitoring Celery workers, tasks and events in Go (Distributed Systems / Advanced Console UIs)
- Go-awesome - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Search and Analytic Databases)
- awesome-go-cn - celeriac
- awesome-go-handwritten - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- awesome-go - celeriac - 利用 Go 語言對Celery 的 worker,任務,事件進行交互和監控的庫 (分佈式系統 / 高級控制台界面)
- awesome-go2 - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- awesome-go - celeriac - A library for adding support for interacting and monitoring Celery workers, tasks and events in Go (Distributed Systems / Advanced Console UIs)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Search and Analytic Databases)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Advanced Console UIs)
- awesome-resources - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Uncategorized / Uncategorized)
- awesome-go-zh - celeriac
- awesome-go-cn - celeriac
- awesome-go-cn - celeriac
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Search and Analytic Databases)
- awesome-go - celeriac - Library for adding support for interacting and monitoring Celery workers, tasks and events in Go. (Distributed Systems / Search and Analytic Databases)
- awesome-go-cn - celeriac
- go-awesome-cn-star - celeriac
- awesome-go - celeriac.v1 - Golang client library for adding support for interacting and monitoring Celery workers, tasks and events. - ★ 43 (Distributed Systems)
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 both 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/mailru/easyjson## Install `easyjson`
```bash
$ go get -u github.com/mailru/easyjson/...
```## Usage
Installation: `go get github.com/svcavallar/celeriac.v1`
This imports a new namespace called `celeriac`
```go
package mainimport (
"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)
// Go routine to monitor the Celery events emitted on the celeriac events channel
go func() {
for {
select {
default:
ev := <-TaskQueueMgr.Monitor.EventsChannelif ev != nil {
if x, ok := ev.(*celeriac.WorkerEvent); ok {
log.Printf("Celery Event Channel: Worker event - %s [Hostname]: %s", x.Type, x.Hostname)
} else if x, ok := ev.(*celeriac.TaskEvent); ok {
log.Printf("Celery Event Channel: Task event - %s [ID]: %s", x.Type, x.UUID)
} else if x, ok := ev.(*celeriac.Event); ok {
log.Printf("Celery Event Channel: General event - %s [Hostname]: %s - [Data]: %v", x.Type, x.Hostname, x.Data)
} else {
log.Printf("Celery Event Channel: Unhandled event: %v", ev)
}
}
}
}
}()
}
```## Dispatching Tasks
### By Name
This will create and dispatch a task incorporating the supplied data. The task will automatically be allocated and identified by a UUID returned in the task object. The UUID is represented in the form of "6ba7b810-9dad-11d1-80b4-00c04fd430c8".// Dispatch a new task
taskName := "root.test.task"
taskData := map[string]interface{}{
"foo": "bar"
}
routingKey := "root.test"task, err := TaskQueueMgr.DispatchTask(taskName, taskData, routingKey)
if err != nil {
log.Errorf("Failed to dispatch task to queue: %v", err)
}### By ID & Name
This will create and dispatch a task incorporating the supplied data, and identified by the user-supplied task identifier.// Dispatch a new task
taskID := "my_task_id_123456789"
taskName := "root.test.task"
taskData := map[string]interface{}{
"foo": "bar"
}
routingKey := "root.test"task, err := TaskQueueMgr.DispatchTaskWithID(taskID, taskName, taskData, routingKey)
if err != nil {
log.Errorf("Failed to dispatch task to queue: %v", err)
}## Modifying `task_event.go`
If you modify the properties of any the structs in `task_event.go` you will need to re-generate the `easyjson` version of this file. This is easily achieved by issuing the following command:
```bash
$ easyjson -all task_eventtest.go
```
## Processing Redis Backend Result AutomaticallyIf you are using a Redis backend for storing results you can easily process new/updated entries by subscribing to Redis keyspace events.
This will save polling for results, and is made convenient to integrate by using my golang helper package `go-redis-event-sink`, available at the repo [https://github.com/svcavallar/go-redis-event-sink](https://github.com/svcavallar/go-redis-event-sink)An example on how to use this is provided within the repository. Essentially, just provide it with the Celery task naming mask patten to watch: `celery-task-meta-*`