feat: Add Actor method use_state#738
Conversation
|
Let's please wait until the implementation is clarified in #735. |
There was a problem hiding this comment.
Pull request overview
This PR adds a new use_state method to the Actor class, enabling users to easily create and manage state values that are automatically persisted to key-value stores. The state is persisted periodically (based on PERSIST_STATE_INTERVAL_MILLIS) and also when the Actor exits.
Changes:
- Added
Actor.use_state()method for managing persistent state - Implemented automatic state persistence on Actor exit via
_save_actor_state() - Added comprehensive unit tests covering default and custom configurations
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/apify/_actor.py | Implements the use_state method, adds state store tracking, and integrates state persistence into Actor lifecycle |
| tests/unit/actor/test_actor_key_value_store.py | Adds unit tests for the new use_state functionality with various scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
quite good comments from copilot 🙂 |
vdusek
left a comment
There was a problem hiding this comment.
Ok, thanks for resolving those comments from Copilot, LGTM from my side, let's wait for @Pijukatel and merge it.
Description
Add
Actormethoduse_state. Allows the user to save data and states in kvs with periodic persistence.Issues
Closes: #735
Testing
Added unit tests