28 lines
557 B
Go
28 lines
557 B
Go
package queue
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"forgejo.digital-droplets.de/philschlo/proxui/platform/jobs"
|
|
"github.com/hibiken/asynq"
|
|
)
|
|
|
|
type Enqueuer struct {
|
|
client *asynq.Client
|
|
}
|
|
|
|
func NewEnqueuer(client *asynq.Client) Enqueuer {
|
|
return Enqueuer{client: client}
|
|
}
|
|
|
|
func (e Enqueuer) EnqueueProxmoxTaskPoll(ctx context.Context, payload jobs.ProxmoxTaskPollPayload) error {
|
|
body, err := json.Marshal(payload)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
_, err = e.client.EnqueueContext(ctx, asynq.NewTask(jobs.TypeProxmoxTaskPoll, body))
|
|
return err
|
|
}
|