Code Monkey home page Code Monkey logo

tasq's Introduction

godoc for greencoda/tasq Build Status Go 1.19 Go Report card

tasq

Tasq is Golang task queue using SQL database for persistence. Currently supports:

  • PostgreSQL
  • MySQL

Install

go get -u github.com/greencoda/tasq

Usage Example

To try tasq locally, you'll need a local DB running on your machine. You may use the supplied docker-compose.yml file to start a local instance

docker-compose -f _examples/<example_repo_name>/docker-compose.yml up -d

Afterwards simply run the example.go file

go run _examples/<example_repo_name>/main.go

tasq's People

Contributors

greencoda avatar zchunhai avatar

Stargazers

 avatar Panayotis Manganaris avatar Eliana Abraham avatar  avatar H avatar Emil Valeev avatar Vignan Posham avatar  avatar Mikkel Kamstrup Erlandsen avatar renothing avatar Can Evgin avatar sowiner avatar  avatar NadnaN avatar Song Liu avatar 卜木 avatar tekmanic avatar thiagoscherrer avatar Josh avatar Jimmy Nelle avatar  avatar Ochi Daiki avatar SzarvasSzilardMW avatar Vincent Serpoul avatar Harish Patel avatar Jaemin Noh avatar Alexey Melezhik avatar Liam G avatar @karantin2020 avatar Emmanuel Ay avatar Park Sang kil avatar Aidan Blancas avatar Jianbo Yan avatar Abiodun Azeez avatar yuvaraj avatar Nguyễn Công Minh avatar Eli avatar Jason White avatar Sean Prouty avatar Christian Korneck avatar Hafiz Shafruddin avatar  avatar metacatdud avatar  Ross Berry avatar David Mair Spiess avatar Hristo Karchokov avatar SouthWolf avatar  avatar

Watchers

 avatar

tasq's Issues

fatal error: concurrent map writes

Hello @greencoda , I use goroutine worker pool to process tasks concurrently. As follows:

func ConsumeTasks(ctx context.Context, c *tasq.Consumer, conf *config.RouterConfig) {
	logger.Info("Begin Consume Tasks")
	// Create an unbuffered (blocking) pool with a fixed number of workers
	pool := pond.New(10, 0, pond.MinWorkers(10), pond.Context(ctx))

	for {
		job := <-c.Channel()
		if job == nil {
			continue
		}

		pool.Submit(*job)

		select {
		case <-ctx.Done():
			logger.Info("consume tasks stop")
			return
		default:
			continue
		}
	}

	// unreachable code
	// pool.StopAndWait()
}

During operation, the following error will occasionally be reported:

fatal error: concurrent map writes


goroutine 149 [running]:
github.com/greencoda/tasq.(*Consumer).removeFromActiveTasks(...)
    /app/vendor/github.com/greencoda/tasq/consumer.go:338
github.com/greencoda/tasq.(*Consumer).registerTaskSuccess(0xc0004382c0, {0x10d1a88?, 0x1746dc0?}, 0xc0002886e0)
    /app/vendor/github.com/greencoda/tasq/consumer.go:312 +0x91
github.com/greencoda/tasq.(*Consumer).createJobFromTask.(*Consumer).newJob.func1()
    /app/vendor/github.com/greencoda/tasq/consumer.go:491 +0x93
github.com/alitto/pond.(*WorkerPool).executeTask(0xc000000e40, 0x0?, 0x0?)
    /app/vendor/github.com/alitto/pond/pond.go:454 +0x6c
github.com/alitto/pond.worker({0x10d1b30, 0xc0005527d0}, 0x0?, 0x0?, 0xc000403260, 0xc000556c00)
    /app/vendor/github.com/alitto/pond/worker.go:32 +0xc2
created by github.com/alitto/pond.(*WorkerPool).maybeStartWorker in goroutine 105
    /app/vendor/github.com/alitto/pond/pond.go:423 +0x133

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.