From 088119d4dc5866a1790d9a63f92c400fc06180b4 Mon Sep 17 00:00:00 2001 From: tbuchaillot Date: Wed, 31 Jan 2024 18:25:31 +0100 Subject: [PATCH] linting --- persistent/model/object_id_test.go | 1 - temporal/internal/driver/redisv9/keyvalue.go | 8 +++++--- temporal/model/types.go | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/persistent/model/object_id_test.go b/persistent/model/object_id_test.go index 779b9d35..032a4eb1 100644 --- a/persistent/model/object_id_test.go +++ b/persistent/model/object_id_test.go @@ -92,7 +92,6 @@ func TestUnmarshalJSON(t *testing.T) { var id2 ObjectID err = id2.UnmarshalJSON(idBytes) - if err != nil { t.Fatal(err) } diff --git a/temporal/internal/driver/redisv9/keyvalue.go b/temporal/internal/driver/redisv9/keyvalue.go index c1402546..adea4f55 100644 --- a/temporal/internal/driver/redisv9/keyvalue.go +++ b/temporal/internal/driver/redisv9/keyvalue.go @@ -195,7 +195,6 @@ func (r *RedisV9) DeleteScanMatch(ctx context.Context, pattern string) (int64, e case *redis.Client: var err error totalDeleted, err = r.deleteScanMatchSingleNode(ctx, client, pattern) - if err != nil { if errors.Is(err, redis.ErrClosed) { return totalDeleted, temperr.ClosedConnection @@ -218,7 +217,6 @@ func (r *RedisV9) deleteScanMatchSingleNode(ctx context.Context, client redis.Cm var keys []string keys, _, err = client.Scan(ctx, cursor, pattern, 0).Result() - if err != nil { return int64(deleted), err } @@ -486,5 +484,9 @@ func (r *RedisV9) SetIfNotExist(ctx context.Context, key, value string, expirati } res := r.client.SetNX(ctx, key, value, expiration) - return res.Val(), res.Err() + if res.Err() != nil { + return false, res.Err() + } + + return res.Val(), nil } diff --git a/temporal/model/types.go b/temporal/model/types.go index 163472a5..95697508 100644 --- a/temporal/model/types.go +++ b/temporal/model/types.go @@ -55,7 +55,8 @@ type KeyValue interface { Get(ctx context.Context, key string) (value string, err error) // Set sets the string value of a key Set(ctx context.Context, key, value string, ttl time.Duration) error - // SetIfNotExist sets the string value of a key if the key does not exist. Returns true if the key was set, false otherwise. + // SetIfNotExist sets the string value of a key if the key does not exist. + // Returns true if the key was set, false otherwise. SetIfNotExist(ctx context.Context, key, value string, expiration time.Duration) (bool, error) // Delete removes the specified keys Delete(ctx context.Context, key string) error