Description
Go Client/Worker for Celery Distributed Task Queue https://github.com/shicky/gocelery/blob/master/README.md
gocelery alternatives and similar packages
Based on the "Distributed Systems" category.
Alternatively, view gocelery alternatives based on common mentions on social networks and blogs.
-
Nomad
Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations. -
go-zero
DISCONTINUED. go-zero is a web and rpc framework written in Go. It's born to ensure the stability of the busy sites with resilient design. Builtin goctl greatly improves the development productivity. [Moved to: https://github.com/zeromicro/go-zero] -
rpcx
Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily. Try it. Test it. If you feel it's better, use it! ๐๐๐ฏ๐ๆ๐๐ฎ๐๐๐จ, ๐๐จ๐ฅ๐๐ง๐ ๆ๐ซ๐ฉ๐๐ฑ! build for cloud! -
Encore
Development Platform for building robust type-safe distributed systems with declarative infrastructure -
gleam
Fast, efficient, and scalable distributed map/reduce system, DAG execution, in memory or on disk, written in pure Go, runs standalone or distributedly. -
glow
Glow is an easy-to-use distributed computation system written in Go, similar to Hadoop Map Reduce, Spark, Flink, Storm, etc. I am also working on another similar pure Go system, https://github.com/chrislusf/gleam , which is more flexible and more performant. -
Olric
Distributed in-memory object store. It can be used as an embedded Go library and a language-independent service. -
Dragonfly
Dragonfly is an open source P2P-based file distribution and image acceleration system. It is hosted by the Cloud Native Computing Foundation (CNCF) as an Incubating Level Project. -
go-doudou
go-doudou๏ผdoudou pronounce /dษudษu/๏ผis OpenAPI 3.0 (for REST) spec and Protobuf v3 (for grpc) based lightweight microservice framework. It supports monolith service application as well. -
resgate
A Realtime API Gateway used with NATS to build REST, real time, and RPC APIs, where all your clients are synchronized seamlessly. -
go-sundheit
A library built to provide support for defining service health for golang services. It allows you to register async health checks for your dependencies and the service itself, provides a health endpoint that exposes their status, and health metrics. -
Maestro
Take control of your data, connect with anything, and expose it anywhere through protocols such as HTTP, GraphQL, and gRPC. -
celeriac
Golang client library for adding support for interacting and monitoring Celery workers, tasks and events. -
drmaa
Compute cluster (HPC) job submission library for Go (#golang) based on the open DRMAA standard.
InfluxDB - Purpose built for real-time analytics at any scale.
Do you think we are missing an alternative of gocelery or a related project?
Popular Comparisons
README
gocelery
Go Client/Server for Celery Distributed Task Queue
Why?
Having been involved in several projects migrating servers from Python to Go, I have realized Go can improve performance of existing python web applications. As Celery distributed tasks are often used in such web applications, this library allows you to both implement celery workers and submit celery tasks in Go.
You can also use this library as pure go distributed task queue.
Go Celery Worker in Action
Supported Brokers/Backends
Now supporting both Redis and AMQP!!
- Redis (broker/backend)
- AMQP (broker/backend) - does not allow concurrent use of channels
Celery Configuration
Celery must be configured to use json instead of default pickle encoding. This is because Go currently has no stable support for decoding pickle objects. Pass below configuration parameters to use json.
Starting from version 4.0, Celery uses message protocol version 2 as default value.
GoCelery does not yet support message protocol version 2, so you must explicitly set CELERY_TASK_PROTOCOL
to 1.
CELERY_TASK_SERIALIZER='json',
CELERY_ACCEPT_CONTENT=['json'], # Ignore other content
CELERY_RESULT_SERIALIZER='json',
CELERY_ENABLE_UTC=True,
CELERY_TASK_PROTOCOL=1,
Example
GoCelery GoDoc has good examples.
Also take a look at example
directory for sample python code.
GoCelery Worker Example
Run Celery Worker implemented in Go
// create redis connection pool
redisPool := &redis.Pool{
Dial: func() (redis.Conn, error) {
c, err := redis.DialURL("redis://")
if err != nil {
return nil, err
}
return c, err
},
}
// initialize celery client
cli, _ := gocelery.NewCeleryClient(
gocelery.NewRedisBroker(redisPool),
&gocelery.RedisCeleryBackend{Pool: redisPool},
5, // number of workers
)
// task
add := func(a, b int) int {
return a + b
}
// register task
cli.Register("worker.add", add)
// start workers (non-blocking call)
cli.StartWorker()
// wait for client request
time.Sleep(10 * time.Second)
// stop workers gracefully (blocking call)
cli.StopWorker()
Python Client Example
Submit Task from Python Client
from celery import Celery
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379'
)
@app.task
def add(x, y):
return x + y
if __name__ == '__main__':
ar = add.apply_async((5456, 2878), serializer='json')
print(ar.get())
Python Worker Example
Run Celery Worker implemented in Python
from celery import Celery
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379'
)
@app.task
def add(x, y):
return x + y
celery -A worker worker --loglevel=debug --without-heartbeat --without-mingle
GoCelery Client Example
Submit Task from Go Client
// create redis connection pool
redisPool := &redis.Pool{
Dial: func() (redis.Conn, error) {
c, err := redis.DialURL("redis://")
if err != nil {
return nil, err
}
return c, err
},
}
// initialize celery client
cli, _ := gocelery.NewCeleryClient(
gocelery.NewRedisBroker(redisPool),
&gocelery.RedisCeleryBackend{Pool: redisPool},
1,
)
// prepare arguments
taskName := "worker.add"
argA := rand.Intn(10)
argB := rand.Intn(10)
// run task
asyncResult, err := cli.Delay(taskName, argA, argB)
if err != nil {
panic(err)
}
// get results from backend with timeout
res, err := asyncResult.Get(10 * time.Second)
if err != nil {
panic(err)
}
log.Printf("result: %+v of type %+v", res, reflect.TypeOf(res))
Sample Celery Task Message
Celery Message Protocol Version 1
{
"expires": null,
"utc": true,
"args": [5456, 2878],
"chord": null,
"callbacks": null,
"errbacks": null,
"taskset": null,
"id": "c8535050-68f1-4e18-9f32-f52f1aab6d9b",
"retries": 0,
"task": "worker.add",
"timelimit": [null, null],
"eta": null,
"kwargs": {}
}
Projects
Please let us know if you use gocelery in your project!
Contributing
You are more than welcome to make any contributions. Please create Pull Request for any changes.
LICENSE
The gocelery is offered under MIT license.
*Note that all licence references and agreements mentioned in the gocelery README section above
are relevant to that project's source code only.