From be581c1003e82594e3f5c346871468d9fc2bf0bc Mon Sep 17 00:00:00 2001 From: zhaori96 Date: Fri, 3 May 2024 14:54:19 -0300 Subject: [PATCH 1/3] refactor: set ExtendExpiration default value as true in DefaultRotatorSettingss() --- krot.go | 1 + 1 file changed, 1 insertion(+) diff --git a/krot.go b/krot.go index a9327f2..e065764 100644 --- a/krot.go +++ b/krot.go @@ -126,6 +126,7 @@ func DefaultRotatorSettings() *RotatorSettings { KeyExpiration: DefaultKeyExpiration, RotationInterval: DefaultRotationInterval, AutoClearExpiredKeys: true, + ExtendExpiration: true, KeyProvidingMode: AutoKeyProvidingMode, } } From a15784c6db7a8820cbf989e1877df9a82519e8fb Mon Sep 17 00:00:00 2001 From: zhaori96 Date: Fri, 3 May 2024 14:55:12 -0300 Subject: [PATCH 2/3] bugfix: change the logic of checking RotationInternval and KeyExpiration in Validate() --- krot.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/krot.go b/krot.go index e065764..752f2ce 100644 --- a/krot.go +++ b/krot.go @@ -141,7 +141,7 @@ func (s *RotatorSettings) Validate() error { ) } - if s.RotationInterval < 0 { + if s.RotationInterval <= 0 { return fmt.Errorf( "%w: rotation interval must be greater than 0 (got %s)", ErrInvalidRotationInterval, @@ -149,7 +149,7 @@ func (s *RotatorSettings) Validate() error { ) } - if s.KeyExpiration < 0 { + if s.KeyExpiration <= 0 { return fmt.Errorf( "%w: key expiration must be greater than 0 (got %s)", ErrInvalidKeyExpiration, From 91ac1e2e0e649e012cc98c8f0d3b64f0f1136c8d Mon Sep 17 00:00:00 2001 From: zhaori96 Date: Fri, 3 May 2024 14:56:42 -0300 Subject: [PATCH 3/3] refactor: add 1 extra second to the intervaof the cleaner --- krot.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/krot.go b/krot.go index 752f2ce..82aa04b 100644 --- a/krot.go +++ b/krot.go @@ -800,7 +800,8 @@ func (r *Rotator) Start() error { } if r.settings.AutoClearExpiredKeys { - r.cleaner.Start(context.Background(), r.settings.KeyExpiration) + interval := r.settings.KeyExpiration + time.Second + r.cleaner.Start(context.Background(), interval) } r.controller.TurnOn()