Skip to content

Latest commit

 

History

History
182 lines (117 loc) · 3.8 KB

README.md

File metadata and controls

182 lines (117 loc) · 3.8 KB

Task Queue Asynq

Inspired by Sidekiq from Ruby, I try to make Simple Task App for Queue Processing with the help of Asynq library and Asynqmon to Serve Monitoring Dashboard. Written with Go language.

Requirements

  • Redis
  • Go >= 1.18
  • Kraken.io Account
  • Firebase Account

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

REDIS_URL

KRAKEN_API_KEY

KRAKEN_API_SECRET

FIREBASE_PROJECT_ID

FIREBASE_DATABASE_URL

PORT <= Optional

Precondition

Before run this app, you must:

  1. Create an account at https://kraken.io/ then copy your API Key and Secret.
  2. Generate Firebase service account key:
    1. In the Firebase console, open Settings > Service Accounts.
    2. Click Generate New Private Key, then confirm by clicking Generate Key.
    3. Copy service account (.json) to go root dir and rename to serviceAccountKey.json

Run Locally

Clone the project

  git clone https://github.com/pengdst/task-queue-asynq.git

Or Using SSH

  git clone [email protected]:pengdst/task-queue-asynq.git

Go to the project directory

  cd task-queue-asynq

Create environment file

  cp .env.example .env 

Install dependencies

  go mod download
  go mod tidy

Start the server

  go run task-queue-asynq/cmd/client
  go run task-queue-asynq/cmd/server

Using docker-compose

Go to the project directory

  cd task-queue-asynq

Create docker-compose.yml file and fill environment

  cp docker-compose.yml.example docker-compose.yml 

Start the server

  docker-compose up

or Start and Build the image

  docker-compose up --build

API Reference

Show Dashboard

  GET /dashboard

Email Delivery

Takes user_id and template_id and return message queue task status.

  POST /email/delivery
Parameter Type Description
user_id int Required.
template_id string Required.
Response
{
  "message": "enqueued tasks: id=9130232c-4ebc-4fe9-b8ef-f0ead0c0ec01 queue=low"
}

Image Resize

Takes image_url and return message queue task status.

  POST /image/resize
Parameter Type Description
image_url string Required.
Response
{
  "message": "enqueued tasks: id=9130232c-4ebc-4fe9-b8ef-f0ead0c0ec01 queue=low"
}

Authors

Acknowledgements

Tech Stack

API Client: Resty

Server: Gin

Image Resize: Kraken

Firebase: Firebase Messaging, Firebase Database

Contributing

Contributions are always welcome!