Note
This project is in the Experimental Stage.
We declare this project experimental to set clear expectations for your usage. There could be known or unknown bugs, the API could evolve, or the project could be discontinued if it does not find community adoption. While we cannot provide professional support for experimental projects, we’d be happy to hear from you if you see value in this project!
QStash is an HTTP based messaging and scheduling solution for serverless and edge runtimes.
Use go get to install the Upstash QStash package:
go get github.com/upstash/qstash-go
Import the Upstash QStash package in your project:
import "github.com/upstash/qstash-go"
client := qstash.NewClient("<QSTASH_TOKEN>")
// Error checking is omitted for breavity
res, _ := client.PublishJSON(qstash.PublishJSONOptions{
Url: "https://example.com",
Body: map[string]any{
"hello": "world",
},
Headers: map[string]string{
"test-header": "test-value",
},
})
fmt.Println(res.MessageId)
client := qstash.NewClient("<QSTASH_TOKEN>")
scheduleId, err := client.Schedules().Create(qstash.ScheduleOptions{
Destination: "https://example.com",
Cron: "*/5 * * * *",
})
// handle err
fmt.Print(scheduleId)
receiver := qstash.NewReceiver("<CURRENT_SIGNING_KEY>", "NEXT_SIGNING_KEY")
// ... in your request handler
signature := req.Header.Get("Upstash-Signature")
body, err := io.ReadAll(req.Body)
// handle err
err := receiver.Verify(qstash.VerifyOptions{
Signature: signature,
Body: string(body),
Url: "https://example.com", // optional
})
// handle err
Additional methods are available for managing url groups, schedules, and messages.