mirror of
https://github.com/acaloiaro/neoq
synced 2026-07-21 10:12:18 +00:00
27 lines
551 B
Go
27 lines
551 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"time"
|
|
|
|
"github.com/acaloiaro/neoq"
|
|
)
|
|
|
|
func main() {
|
|
const queue = "foobar"
|
|
nq, _ := neoq.New("postgres://postgres:postgres@127.0.0.1:5432/neoq?sslmode=disable", neoq.TransactionTimeoutOpt(1000))
|
|
|
|
// Add a job that will execute 1 hour from now
|
|
jobID, err := nq.Enqueue(neoq.Job{
|
|
Queue: queue,
|
|
Payload: map[string]interface{}{
|
|
"message": "hello, future world",
|
|
},
|
|
RunAfter: time.Now().Add(1 * time.Hour),
|
|
})
|
|
if err != nil {
|
|
log.Println("error adding job", err)
|
|
}
|
|
|
|
log.Println("added job:", jobID)
|
|
}
|