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.
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{...})
Install go1.18.x
Assuming that you have golang installed, set up your environment like so:
$ cd ${GOPATH}/src/github.com/cloudchacho/taskhawk-go
$ go build
$ make test
# OR
$ go test -tags test ./...
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
Current version: v0.2.0-dev
- Initial version