diff --git a/app/routers/put.go b/app/routers/put.go index b7bc2c0..cfd9834 100644 --- a/app/routers/put.go +++ b/app/routers/put.go @@ -5,12 +5,14 @@ import ( "net/http" tasks "queues-go/app/storage/mongo/collections" "time" + + "go.mongodb.org/mongo-driver/bson" ) type PutRequestBody struct { - Payload json.RawMessage `json:"payload"` - SecondsToExecute int `json:"seconds_to_execute"` - Delay *int `json:"delay"` + Payload bson.M `json:"payload"` + SecondsToExecute int `json:"seconds_to_execute"` + Delay *int `json:"delay"` } func Put(w http.ResponseWriter, r *http.Request) { diff --git a/app/storage/mongo/collections/tasks.go b/app/storage/mongo/collections/tasks.go index 089a65a..a0733b2 100644 --- a/app/storage/mongo/collections/tasks.go +++ b/app/storage/mongo/collections/tasks.go @@ -23,13 +23,13 @@ type Task struct { } type InsertedTask struct { - Queue string `bson:"queue"` - Payload interface{} `bson:"payload"` - PutAt time.Time `bson:"put_at"` - AvailableFrom time.Time `bson:"available_from"` - SecondsToExecute int `bson:"seconds_to_execute"` - TakenAt *time.Time `bson:"taken_at"` - Attempts int `bson:"attempts"` + Queue string `bson:"queue"` + Payload bson.M `bson:"payload"` + PutAt time.Time `bson:"put_at"` + AvailableFrom time.Time `bson:"available_from"` + SecondsToExecute int `bson:"seconds_to_execute"` + TakenAt *time.Time `bson:"taken_at"` + Attempts int `bson:"attempts"` } func Add(task InsertedTask) error {