All Projects → mcmathja → Curlyq

mcmathja / Curlyq

Licence: mit
Efficient and reliable background processing for Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Curlyq

Asynq
Asynq: simple, reliable, and efficient distributed task queue in Go
Stars: ✭ 934 (+749.09%)
Mutual labels:  background-jobs, redis
Lowkiq
Ordered background jobs processing
Stars: ✭ 129 (+17.27%)
Mutual labels:  background-jobs, redis
Qutee
PHP Background Jobs (Tasks) Manager
Stars: ✭ 63 (-42.73%)
Mutual labels:  background-jobs, redis
Node Celery
Celery client for Node.js
Stars: ✭ 648 (+489.09%)
Mutual labels:  background-jobs, redis
Rq
Simple job queues for Python
Stars: ✭ 8,065 (+7231.82%)
Mutual labels:  background-jobs, redis
Kiq
📮 Robust job queue powered by GenStage and Redis
Stars: ✭ 49 (-55.45%)
Mutual labels:  background-jobs, redis
Django Rq
A simple app that provides django integration for RQ (Redis Queue)
Stars: ✭ 1,361 (+1137.27%)
Mutual labels:  background-jobs, redis
Mall
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
Stars: ✭ 54,797 (+49715.45%)
Mutual labels:  redis
Blog
我的日记
Stars: ✭ 110 (+0%)
Mutual labels:  redis
Redis
Async Redis Client for PHP based on Amp.
Stars: ✭ 107 (-2.73%)
Mutual labels:  redis
Ymate Platform V2
YMP是一个非常简单、易用的轻量级Java应用开发框架,涵盖AOP、IoC、WebMVC、ORM、Validation、Plugin、Serv、Cache等特性,让开发工作像搭积木一样轻松!
Stars: ✭ 106 (-3.64%)
Mutual labels:  redis
Cslearning
开源项目之「计算机编程自学之路」:计算机自学指南+面试大全+资源分享+技术文章
Stars: ✭ 107 (-2.73%)
Mutual labels:  redis
Tedis
redis client with typescript and esnext for nodejs
Stars: ✭ 109 (-0.91%)
Mutual labels:  redis
Flink Learning
flink learning blog. http://www.54tianzhisheng.cn/ 含 Flink 入门、概念、原理、实战、性能调优、源码解析等内容。涉及 Flink Connector、Metrics、Library、DataStream API、Table API & SQL 等内容的学习案例,还有 Flink 落地应用的大型项目案例(PVUV、日志存储、百亿数据实时去重、监控告警)分享。欢迎大家支持我的专栏《大数据实时计算引擎 Flink 实战与性能优化》
Stars: ✭ 11,378 (+10243.64%)
Mutual labels:  redis
Spring Boot Examples
🥗​ Spring/SpringBoot/SpringCloud 实践学习案例,从入门到精通,持续更新中,欢迎交流学习🍺 !
Stars: ✭ 110 (+0%)
Mutual labels:  redis
Speedbump
A Redis-backed rate limiter in Go
Stars: ✭ 107 (-2.73%)
Mutual labels:  redis
Django Bruteforce Protection
Bruteforce protection for Django projects based on Redis. Simple, powerful, extendable.
Stars: ✭ 110 (+0%)
Mutual labels:  redis
Identityserver4.contrib.redisstore
A persistence layer using Redis DB for operational data and for caching capability for Identity Server 4
Stars: ✭ 108 (-1.82%)
Mutual labels:  redis
Jadedock
使用 Docker 快速部署简易的 Ngixn + PHP + MySQL + Redis 环境(可开发、可线上运行)
Stars: ✭ 109 (-0.91%)
Mutual labels:  redis
Entangled
Rails in real time
Stars: ✭ 108 (-1.82%)
Mutual labels:  redis

CurlyQ

GoDoc Build Status GoCover Go Report Card License

CurlyQ provides a simple, easy-to-use interface for performing background processing in Go. It supports scheduled jobs, job deduplication, and configurable concurrent execution out of the box.

Quickstart

package main

import (
	"context"
	"log"

	cq "github.com/mcmathja/curlyq"
)

func main() {
	// Create a new producer
	producer := cq.NewProducer(&cq.ProducerOpts{
		Address: "localhost:6379",
		Queue: "testq",
	})

	// Use the producer to push a job to the queue
	producer.Perform(cq.Job{
		Data: []byte("Some data!"),
	})

	// Create a new consumer
	consumer := cq.NewConsumer(&cq.ConsumerOpts{
		Address: "localhost:6379",
		Queue: "testq",
	})

	// Consume jobs from the queue with the consumer
	consumer.Consume(func(ctx context.Context, job cq.Job) error {
		log.Println(string(job.Data))
		return nil
	})
}

The Basics

CurlyQ exposes three key types: Jobs, Producers, and Consumers.

Jobs

A Job wraps your data. In most cases, that's all you'll ever need to know about it:

job := cq.Job{
	Data: []byte("Some data."),
}

Every Job also exposes an ID field that uniquely identifies it among all jobs in the queue, and an Attempt field representing how many times it has been attempted so far.

Producers

A Producer pushes jobs on to the queue. Create one by providing it with the address of your Redis instance and a queue name:

producer := cq.NewProducer(&cq.ProducerOpts{
	Address: "my.redis.addr:6379",
	Queue: "queue_name",
})

You can also provide an existing go-redis instance if you would like to configure the queue to run on a more advanced Redis configuration or set up your own retry and timeout logic for network calls:

import "github.com/go-redis/redis/v7"

client := redis.NewClient(&redis.Options{
	Password: "[email protected]",
	DB: 3,
	MaxRetries: 2,
})

producer := cq.NewProducer(&cq.ProducerOpts{
	Client: client,
	Queue: "queue_name",
})

Running producer.Perform(job) will add a job to the queue to be run asynchronously. You can also schedule a job to be enqueued at a particular time by running producer.PerformAt(time, job), or after a certain wait period by running producer.PerformAfter(duration, job). All of the Perform methods return the ID assigned to the job and an error if one occurred.

You can deduplicate jobs by pre-assigning them IDs:

job := cq.Job{
	ID: "todays_job",
}

// Enqueue the job
producer.PerformAfter(10 * time.Second, job)

// Does nothing, because a job with the same ID is already on the queue
producer.Perform(job)

Once a job has been acknowledged, its ID becomes available for reuse.

See the documentation for ProducerOpts for more details about available configuration options.

Consumers

A Consumer pulls jobs off the queue and executes them using a provided handler function. Create one with the same basic options as a Producer:

consumer := cq.NewConsumer(&cq.ConsumerOpts{
	Queue: "queue_name",

	// With an address:
	Address: "my.redis.addr:6379",
	// With a preconfigured go-redis client:
	Client: redisClient,
})

You start a consumer by running its Consume method with a handler function:

consumer.Consume(func(ctx context.Context, job cq.Job) error {
	log.Println("Job %s has been processed!")
	return nil
})

If the provided handler function returns nil, the job is considered to have been processed successfully and is removed from the queue. If the handler returns an error or panics, the job is considered to have failed and will be retried or killed based on how many times it has been attempted.

Consume will continue to process jobs until your application receives an interrupt signal or the consumer encounters a fatal error. Fatal errors only occur when the consumer is unable to communicate with Redis for an essential operation, such as updating the status of a job in flight.

See the documentation for ConsumerOpts for more details about available configuration options.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].