-
Notifications
You must be signed in to change notification settings - Fork 135
docs: rewrite state persistence #1237
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
Conversation
Restructure content with additional headings & subheadings Simplified language Adjusted heading levels
| ## Implementing state persistence | ||
|
|
||
| The [Apify SDKs](/sdk) handle state persistence automatically. | ||
|
|
||
| In JavaScript, this is done using the `migrating` and `persistState` events in the [PlatformEventManager](/sdk/js/api/apify/class/PlatformEventManager). | ||
|
|
||
| - The `persistState` event prompts SDK components to save their state at regular intervals | ||
| - The `migrating` event is triggered just before a migration occurs. | ||
|
|
||
| In Python, state persistence is handled using the `Actor.on()` method and the migrating event, similar to JavaScript. The Apify SDK for Python provides mechanisms to save and retrieve state data. | ||
|
|
||
| - The `migrating` event is triggered just before a migration occurs, allowing you to save your state. | ||
| - To retrieve previously saved state, you can use the `Actor.get_value()` method. |
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.
I believe you could link the PlatformEventManager API reference of both JS and Python implementations.
You can also mention, that the event manager is encapsulated with Actor class, and when you want to interact with that you should use Actor.on and Actor.off. And it will use the underlying event manager instance in Actor.
Or you do not have to mention EventManagers at all and go with just the shortcuts.
vdusek
left a comment
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.
So maybe you could just slightly rewrite the new "Implementing state persistence" section. Mostly things should work the same regardless the JS/Python implementation. So I would get rid of of words like "In Python/JavaScript...". Otherwise it is good, thanks 🙂 .
… event & Actor methods
|
I've removed mentions of PlatformEventManager and left just links to to get values methods in both JS & Python , that seems more elegant and relevant |
fnesveda
left a comment
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.
I had a few suggestions and corrections
sources/platform/actors/development/builds_and_runs/state_persistence.md
Outdated
Show resolved
Hide resolved
sources/platform/actors/development/builds_and_runs/state_persistence.md
Outdated
Show resolved
Hide resolved
sources/platform/actors/development/builds_and_runs/state_persistence.md
Outdated
Show resolved
Hide resolved
sources/platform/actors/development/builds_and_runs/state_persistence.md
Outdated
Show resolved
Hide resolved
sources/platform/actors/development/builds_and_runs/state_persistence.md
Outdated
Show resolved
Hide resolved
sources/platform/actors/development/builds_and_runs/state_persistence.md
Outdated
Show resolved
Hide resolved
sources/platform/actors/development/builds_and_runs/state_persistence.md
Outdated
Show resolved
Hide resolved
Co-authored-by: František Nesveda <[email protected]>
Restructure content with additional headings & subheadings
Simplified language
Adjusted heading levels