This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
Use memo
for arbitrary per-resource payload during operator lifetime
#234
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Since the per-resource in-memory runtime-only containers are already present in the core for internal purposes, it is easy to expose
memo
kwarg to the handlers, so that the can store arbitrary information or objects about resources.Same as for the internal use, this should be the objects that are scoped to the operator life time, fully lost on restarts, i.e. not persistent. E.g. threads, tasks, locks, events. Maybe some regular scalars, if their meaning is also scoped to the operator process.
Example:
In this example,
create_fn_1
raises AttributeError on the 1st attempt, then goes tocreate_fn_2
, and then retriescreate_fn_1
in 10 seconds with the.xyz
field already set.Both dictionary and object interfaces are supported.
The documentation is intentionally limited — let's first see how it will be used, and what can be the examples.
Types of Changes
Review
List of tasks the reviewer must do to review the PR