Skip to content

TaskHawk is a replacement for celery that works on AWS and GCP, while keeping things pretty simple and straightforward. Any unbound function can be converted into a TaskHawk task.

License

Notifications You must be signed in to change notification settings

cloudchacho/taskhawk-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Taskhawk Go

Build Status Go Report Card Godoc codecov

Taskhawk is an async task execution framework (à la celery) that works on AWS and GCP, while keeping things pretty simple and straight forward. Any unbound function can be converted into a Taskhawk task.

Only Go 1.18+ is supported currently.

This project uses semantic versioning.

Quick Start

First, install the library:

go get github.com/cloudchacho/taskhawk-go

If your function takes multiple arguments, convert your function into a "Task" as shown here:

type SendEmailTaskInput struct {...}

func SendEmail(ctx context.Context, input *SendEmailTaskInput) error {
    // send email
}

Tasks may accept input of arbitrary pointer type as long as it's serializable to JSON. Remember to export fields!

Then, define your backend:

settings := aws.Settings{
    AWSAccessKey: <YOUR AWS ACCESS KEY>,
    AWSAccountID: <YOUR AWS ACCOUNT ID>,
    AWSRegion: <YOUR AWS REGION>,
    AWSSecretKey: <YOUR AWS SECRET KEY>,

    Queue: <YOUR TASKHAWK QUEUE>,
}
backend := aws.NewBackend(settings, nil)

Before the task can be dispatched, it would need to be registered, as shown below.

hub := NewHub(Config{...}, backend)
task, err := taskhawk.RegisterTask(hub, "SendEmailTask", SendEmailTask)

And finally, dispatch your task asynchronously:

task.dispatch(&SendEmailTaskInput{...})

Development

Prerequisites

Install go1.18.x

Getting Started

Assuming that you have golang installed, set up your environment like so:

$ cd ${GOPATH}/src/github.com/cloudchacho/taskhawk-go
$ go build

Running tests

$ make test  
# OR
$ go test -tags test ./...

Getting Help

We use GitHub issues for tracking bugs and feature requests.

  • If it turns out that you may have found a bug, please open an issue

Release notes

Current version: v0.2.0-dev

v0.1.0

  • Initial version

About

TaskHawk is a replacement for celery that works on AWS and GCP, while keeping things pretty simple and straightforward. Any unbound function can be converted into a TaskHawk task.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages