https://github.com/jeamon/gorqs
Go-based concurrent-safe library to start and stop a Queue with capabilities to asynchronously push jobs and execute them either into sync or async fashion. Along with capability to fetch their execution results.
https://github.com/jeamon/gorqs
concurrency go golang goroutines-channels job-queue library queue system-programming
Last synced: 10 months ago
JSON representation
Go-based concurrent-safe library to start and stop a Queue with capabilities to asynchronously push jobs and execute them either into sync or async fashion. Along with capability to fetch their execution results.
- Host: GitHub
- URL: https://github.com/jeamon/gorqs
- Owner: jeamon
- License: mit
- Created: 2023-10-20T23:45:33.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-04T23:37:16.000Z (about 2 years ago)
- Last Synced: 2025-01-17T23:17:29.159Z (11 months ago)
- Topics: concurrency, go, golang, goroutines-channels, job-queue, library, queue, system-programming
- Language: Go
- Homepage: https://learn.cloudmentor-scale.com
- Size: 36.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gorqs
[](https://github.com/jeamon/gorqs/actions)
[](https://godoc.org/github.com/jeamon/gorqs)
[](https://goreportcard.com/report/github.com/jeamon/gorqs)
[](https://codecov.io/gh/jeamon/gorqs)

[](https://github.com/jeamon/gorqs/blob/main/LICENSE)
**`gorqs`** means *Go Runnable Queue Service*. This is a multi-features go-based concurrent-safe library to **queue & execute** jobs and records their execution result. You can start the Queue service into synchronous or asynchronous mode.
The mode defines wether each added job should be processed *synchronously* or *asynchronously*. Be aware that adding a job to the Queue system is always a non-blocking operation and returns the job id on success. Fetching a given job execution result removes that entry from local records cache.
## Features
`gorqs.New(gorqs.SyncMode | gorqs.TrackJobs)` or `gorqs.New(gorqs.AsyncMode | gorqs.TrackJobs)` method provides a Queue object which implements the `Queuer` interface with below actions.
| Action | Description |
|:------ | :-------------------------------------- |
| **`Start(context.Context) error`** | starts the jobs queue |
| **`Stop(context.Context) error`** | stops the jobs queue |
| **`Push(context.Context, Runner) (int64, error)`** | adds a job to the queue asynchronously |
| **`Fetch(context.Context, int64) error`** | gets result execution of given job |
| **`IsRunning() bool`** | provides queue service status |
| **`Clear()`** | delete all jobs results records |
*An acceptable runnable job should implement the `Runner` interface defined as below :*
```go
type Runner interface {
Run() error
}
```
## Installation
Just import the `gorqs` library as external package to start using it into your project. There are some examples into the *examples* folder.
**[Step 1] -** Download the package
```shell
$ go get github.com/jeamon/gorqs
```
**[Step 2] -** Import the package into your project
```shell
$ import "github.com/jeamon/gorqs"
```
**[Step 3] -** Optional: Clone the library to run some examples
```shell
$ git clone https://github.com/jeamon/gorqs.git
$ cd gorqs
$ go run examples/sync-mode/example.go
$ go run examples/async-mode/example.go
```
## Contact
Feel free to [reach out to me](https://blog.cloudmentor-scale.com/contact) before any action. Feel free to connect on [Twitter](https://twitter.com/jerome_amon) or [linkedin](https://www.linkedin.com/in/jeromeamon/)