From 265ff4cfe7d8bedcbf4cee862efa0ca4cb0a5b28 Mon Sep 17 00:00:00 2001 From: Zaur Date: Wed, 15 Jan 2025 23:54:39 +0800 Subject: [PATCH] fix ttl field for mongo backend --- v2/backends/mongo/mongodb.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/v2/backends/mongo/mongodb.go b/v2/backends/mongo/mongodb.go index 82d622db..52a6b468 100644 --- a/v2/backends/mongo/mongodb.go +++ b/v2/backends/mongo/mongodb.go @@ -143,7 +143,7 @@ func (b *Backend) SetStateSuccess(signature *tasks.Signature, results []*tasks.T update := bson.M{ "state": tasks.StateSuccess, "results": decodedResults, - "ttl": time.Now().Add(time.Duration(b.GetConfig().ResultsExpireIn) * time.Second), + "delete_at": time.Now().Add(time.Duration(b.GetConfig().ResultsExpireIn) * time.Second), } return b.updateState(signature, update) } @@ -175,7 +175,7 @@ func (b *Backend) SetStateFailure(signature *tasks.Signature, err string) error update := bson.M{ "state": tasks.StateFailure, "error": err, - "ttl": time.Now().Add(time.Duration(b.GetConfig().ResultsExpireIn) * time.Second), + "delete_at": time.Now().Add(time.Duration(b.GetConfig().ResultsExpireIn) * time.Second), } return b.updateState(signature, update) } @@ -346,7 +346,7 @@ func (b *Backend) createMongoIndexes(database string) error { _, err := tasksCollection.Indexes().CreateMany( context.Background(), []mongo.IndexModel{ { - Keys: bson.M{"ttl": 1}, + Keys: bson.M{"delete_at": 1}, Options: options.Index().SetBackground(true).SetExpireAfterSeconds(0), }, },