-
Notifications
You must be signed in to change notification settings - Fork 542
Adds Global TTL Configuration for DynamoDB State Store #4055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Zeynel Koca <[email protected]>
Signed-off-by: Zeynel Koca <[email protected]>
Signed-off-by: Zeynel Koca <[email protected]>
|
Would be nice when the different statestores (Redis and Dynamo) behave in a similar way. |
|
There will be a slight delay in reviewing the DynamoDB-related PRs. We need to address the missing/disabled tests first, which are being tracked in issue #4047. Thanks for your patience! |
| t.Run("Explicit TTL overrides default in request with empty metadata", func(t *testing.T) { | ||
| defaultTTL := 1200 | ||
| s := StateStore{ | ||
| ttlAttributeName: "expiresAt", | ||
| ttlInSeconds: &defaultTTL, | ||
| } | ||
|
|
||
| req := &state.SetRequest{ | ||
| Key: "test-key", | ||
| Metadata: map[string]string{ | ||
| "ttlInSeconds": "0", | ||
| }, | ||
| } | ||
|
|
||
| ttl, err := s.parseTTL(req) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, ttl) | ||
|
|
||
| // Should use explicit value 0, not default | ||
| expectedTime := time.Now().Unix() | ||
| assert.InDelta(t, expectedTime, *ttl, 2) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case demonstrates that the behavior for dynamodb would make the setting of this metadata field to 0 to expire immediately, and the same for a negative value. However, if I look at the SET implementation of the redis implementation a value of 0 for the ttl means the key never expires, as does a negative value. I think we should have the same behavior on dynamodb that we have for redis please 🙏 If you can also create a docs PR to add this PR to the docs too that would be greatly appreciated! Feel free to tag me when this is ready for re-review :)
https://github.com/berndverst/components-contrib/blob/master/state/redis/redis.go#L363
| description: | | ||
| Allows specifying a default Time-to-live (TTL) in seconds that will be applied to every state store request unless TTL is explicitly defined via the request metadata. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| description: | | |
| Allows specifying a default Time-to-live (TTL) in seconds that will be applied to every state store request unless TTL is explicitly defined via the request metadata. | |
| description: | | |
| Allows specifying a Time-to-live (TTL) in seconds that will be applied to every state store request unless TTL is explicitly defined via the request metadata. |
Description
Adds a way to globally configure the state TTL for dynamo (inspired by #1059).
The defined default TTL will only be used if the state request does not explicitly specify a TTL itself.
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: