All Projects → gojuukaze → Ytask

gojuukaze / Ytask

Licence: gpl-3.0
YTask is an asynchronous task queue for handling distributed jobs in golang(go异步任务框架)

Programming Languages

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

Projects that are alternatives of or similar to Ytask

leek
Celery Tasks Monitoring Tool
Stars: ✭ 77 (-36.36%)
Mutual labels:  task, queue, worker, celery
Aint Queue
🚀 An async-queue library built on top of swoole, flexable multi-consumer, coroutine supported. 基于 Swoole 的一个异步队列库,可弹性伸缩的工作进程池,工作进程协程支持。
Stars: ✭ 143 (+18.18%)
Mutual labels:  job, worker, queue
Machinery
Machinery is an asynchronous task queue/job queue based on distributed message passing.
Stars: ✭ 5,821 (+4710.74%)
Mutual labels:  task, task-scheduler, queue
Node Celery
Celery client for Node.js
Stars: ✭ 648 (+435.54%)
Mutual labels:  task, queue, celery
Clearly
Clearly see and debug your celery cluster in real time!
Stars: ✭ 287 (+137.19%)
Mutual labels:  task, queue, celery
qless-php
PHP Bindings for qless
Stars: ✭ 25 (-79.34%)
Mutual labels:  task, queue, worker
Node Rethinkdb Job Queue
A persistent job or task queue backed by RethinkDB.
Stars: ✭ 158 (+30.58%)
Mutual labels:  task, job, queue
linda
Linda is a simple dispatcher library.
Stars: ✭ 12 (-90.08%)
Mutual labels:  task, queue, job
wtsqs
Simplified Node AWS SQS Worker Wrapper
Stars: ✭ 18 (-85.12%)
Mutual labels:  queue, job, worker
orkid-node
Reliable and modern Redis Streams based task queue for Node.js 🤖
Stars: ✭ 61 (-49.59%)
Mutual labels:  queue, job, task-scheduler
celery.node
Celery task queue client/worker for nodejs
Stars: ✭ 164 (+35.54%)
Mutual labels:  queue, worker, celery
Workq
Job server in Go
Stars: ✭ 1,546 (+1177.69%)
Mutual labels:  job, worker, queue
Swiftqueue
Job Scheduler for IOS with Concurrent run, failure/retry, persistence, repeat, delay and more
Stars: ✭ 276 (+128.1%)
Mutual labels:  job, queue
Xxl Job
A distributed task scheduling framework.(分布式任务调度平台XXL-JOB)
Stars: ✭ 20,197 (+16591.74%)
Mutual labels:  task, job
Test-Assignments
List of test assignments. ⚡
Stars: ✭ 85 (-29.75%)
Mutual labels:  task, job
Bull
Bull module for Nest framework (node.js) 🐮
Stars: ✭ 356 (+194.21%)
Mutual labels:  job, queue
Pg Boss
Queueing jobs in Node.js using PostgreSQL like a boss
Stars: ✭ 525 (+333.88%)
Mutual labels:  job, queue
rust-sidekiq
Rust Sidekiq Client
Stars: ✭ 24 (-80.17%)
Mutual labels:  queue, job
Arq
Fast job queuing and RPC in python with asyncio and redis.
Stars: ✭ 695 (+474.38%)
Mutual labels:  worker, queue
Inc.runtime.queue
An runtime queue use Asynchronous program
Stars: ✭ 19 (-84.3%)
Mutual labels:  task, queue

YTask

YTask is an asynchronous task queue for handling distributed jobs in golang
golang异步任务/队列 框架

  • 中文文档 (Chinese document has more detailed instructions. If you know Chinese, read Chinese document)
  • En Doc
  • Github

install

go get -u github.com/gojuukaze/YTask/v2

architecture diagram

architecture_diagram

Quick Start

server demo

package main

import (
	"context"
	"github.com/gojuukaze/YTask/v2"
	"os"
	"os/signal"
	"syscall"
)

type User struct {
	Id   int
	Name string
}

func add(a int, b int) int {
	return a + b
}

func appendUser(user User, ids []int, names []string) []User {
	var r = make([]User, 0)
	r = append(r, user)
	for i := range ids {
		r = append(r, User{ids[i], names[i]})
	}
	return r
}

func main() {
	// clientPoolSize: brokerPoolSize need not be set at server
	//                 -------------
	//                 server端不需要设置brokerPoolSize
	
	broker := ytask.Broker.NewRedisBroker("127.0.0.1", "6379", "", 0, 0)
	// poolSize: Maximum number of idle connections in the pool. If poolSize<=0 use default value
	//           default value is min(10, numWorkers) at server
	//           -------------
	//           如果poolSize<=0 会使用默认值,
	//           对于server端backend PoolSize的默认值是 min(10, numWorkers)	
	backend := ytask.Backend.NewRedisBackend("127.0.0.1", "6379", "", 0, 0)

	ser := ytask.Server.NewServer(
		ytask.Config.Broker(&broker),
		ytask.Config.Backend(&backend),
		ytask.Config.Debug(true),
		ytask.Config.StatusExpires(60*5),
		ytask.Config.ResultExpires(60*5),
	)

	ser.Add("group1", "add", add)
	ser.Add("group1", "append_user", appendUser)

	ser.Run("group1", 3)

	quit := make(chan os.Signal, 1)

	signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
	<-quit
	ser.Shutdown(context.Background())

}

client demo

package main

import (
	"fmt"
	"github.com/gojuukaze/YTask/v2"
	"github.com/gojuukaze/YTask/v2/server"
	"time"
)

type User struct {
	Id   int
	Name string
}

var client server.Client

func main() {
	// clientPoolSize: Maximum number of idle connections in client pool.
	//                 If clientPoolSize<=0, clientPoolSize=10
	//
	broker := ytask.Broker.NewRedisBroker("127.0.0.1", "6379", "", 0, 5)
	
	// poolSize: Maximum number of idle connections in the pool. If poolSize<=0 use default value
	//           default value is 10 at client
	//           ---------------
	//           对于client端,如果poolSize<=0,poolSize会设为10
	backend := ytask.Backend.NewRedisBackend("127.0.0.1", "6379", "", 0, 5)

	ser := ytask.Server.NewServer(
		ytask.Config.Broker(&broker),
		ytask.Config.Backend(&backend),
		ytask.Config.Debug(true),
		ytask.Config.StatusExpires(60*5),
		ytask.Config.ResultExpires(60*5),
	)

	client = ser.GetClient()

	// task add
	taskId, _ := client.Send("group1", "add", 123, 44)
	result, _ := client.GetResult(taskId, 2*time.Second, 300*time.Millisecond)

	if result.IsSuccess() {
		sum, _ := result.GetInt64(0)
		// or
		var sum2 int
		result.Get(0, &sum2)

		fmt.Println("add(123,44) =", int(sum))
	}

	// task append user
	taskId, _ = client.Send("group1", "append_user", User{1, "aa"}, []int{322, 11}, []string{"bb", "cc"})
	result, _ = client.GetResult(taskId, 2*time.Second, 300*time.Millisecond)
	var users []User
	result.Get(0, &users)
	fmt.Println(users)

}

Example

Also take a look at example directory.

cd example/v2
go run server/main.go 

go run send/main.go

捐赠 / Sponsor

开源不易,如果你觉得对你有帮助,求打赏个一块两块的

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].