-
Notifications
You must be signed in to change notification settings - Fork 85
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
FEATURE PREVIEW: Add Actor State TTL support #482
Comments
HI @shubham1172 for the above issue We need to create the separate function in can you go through these function async setStateWithTTL(stateName: string, value: T, ttl: number): Promise<void> {
const stateChangeTracker = this.getContextualStateTracker();
if (stateChangeTracker.has(stateName)) {
const stateMetadata = stateChangeTracker.get(stateName);
if (!stateMetadata) {
return;
}
stateMetadata.setValue(value);
stateMetadata.setTTL(ttl);
if (
stateMetadata.getChangeKind() === StateChangeKind.NONE ||
stateMetadata.getChangeKind() === StateChangeKind.REMOVE
) {
stateMetadata.setChangeKind(StateChangeKind.UPDATE);
}
stateChangeTracker.set(stateName, stateMetadata);
return;
}
const didExist = await this.actor
.getStateProvider()
.containsState(this.actor.getActorType(), this.actor.getActorId(), stateName);
if (didExist) {
stateChangeTracker.set(stateName, new StateMetadata(value, StateChangeKind.UPDATE, ttl));
} else {
stateChangeTracker.set(stateName, new StateMetadata(value, StateChangeKind.ADD, ttl));
}
} |
@shubham1172 any update on this ? |
Hi @salmankhan-prs, yes, you need to create this function in |
@shubham1172 you want async setState(stateName: string, value: T): Promise<void> {
return await setStateWithTTL(name, val, -1).
} |
@shubham1172 Is the above change is want we required or anything else we are looking for? |
@salmankhan-prs yes, please feel free to create a PR, let me assign this issue to you. |
@shubham1172 I made PR.please verify it |
@shubham1172 can you help me to find out where I can write the test case for |
Taking this conversation to the pull request - @salmankhan-prs. |
@salmankhan-prs @shubham1172 I have update the issue description. For v1.11, This feature now requires the |
Can this be added in the next release? |
This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not had activity in the last 67 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions. |
Add first class API support for Actor State TTL dapr/dapr#5899
A dedicated function to Actor State should be created. Psudo code:
func (key string, value string, ttl duration)
. It should be made clear in the SDK documentation/comments that users should always use this function, unless they have specifically created some kind of Actor State clean up out of band of Dapr or don't have an issue with the Actor State store keep state and grow "forever".Please see the go-sdk for implementation reference.
UPDATE: Due to the nature of the current implementation of write through caching of actor state and the unavailability of the real TTL expire time of state keys, SDKs will have an inconsistent view of the world when it has a cold cache and the state store has TTL keys. The TTL functionality has been put behind a feature gate in daprd. See dapr/dapr#6400 for more details. This feature is expected to be moved to GA in 1.12.
The text was updated successfully, but these errors were encountered: