https://github.com/gedex/go-simple-queue
Simulating simple queue with Go
https://github.com/gedex/go-simple-queue
Last synced: over 1 year ago
JSON representation
Simulating simple queue with Go
- Host: GitHub
- URL: https://github.com/gedex/go-simple-queue
- Owner: gedex
- License: mit
- Created: 2014-10-26T17:03:07.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-10-26T17:03:39.000Z (over 11 years ago)
- Last Synced: 2025-02-15T08:25:00.295Z (over 1 year ago)
- Language: Go
- Size: 102 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
go-simple-queue
========================
> Simulating simple queue, written in Go, for pushing and fetching jobs.
Consider a use case where you need to send email after a user is suscessfully
registered. Sending email takes time and it will block request handler to finish
the response. However, you can delay sending email by pushing it into queue and
let the background worker picking up the job later.
## Run
```
$ git clone $THIS_GITHUB_URL
$ cd go-simple-queue
$ go build
$ ./go-simple-queue
Running 'SendEmail' queue with 4 worker(s)
Starting worker 'Worker#SendEmail#1'
Starting worker 'Worker#SendEmail#2'
Starting worker 'Worker#SendEmail#3'
Starting worker 'Worker#SendEmail#4'
Running 'GenerateThumbnail' queue with 3 worker(s)
Starting worker 'Worker#GenerateThumbnail#1'
Starting worker 'Worker#GenerateThumbnail#2'
Starting worker 'Worker#GenerateThumbnail#3'
Worker#SendEmail#1: taking Job#SendEmail#1
Worker#GenerateThumbnail#1: taking Job#GenerateThumbnail#1
Worker#SendEmail#2: taking Job#SendEmail#2
Job#SendEmail#1 done by Worker#SendEmail#1 [SUCCESS]
...
```
Once you built and ran the program, it will publish jobs periodically. There are
4 `SendEmail` workers and 3 `GenerateThumbnail` workers fetching jobs from
queue. Worker will take [0,3) seconds to finish its job. The result may `SUCCESS`
or `FAIL`.
## License
MIT License - see [LICENSE](./LICENSE) file.