Feature: Add support for update callback
mcassaniti opened this issue · 4 comments
When a replicated object is updated and that update is committed, it would be useful to be able to run a callback when the update occurs. For example:
- A replicated dictionary is available across 3 nodes
- One of those nodes makes a change of some form to the dictionary and that update is successfully committed
- All nodes are notified of the change in state of the dictionary and run their callback function
If this is already implemented then I apologise for asking, but it wasn't clear from the documentation.
There is an automatically added callback
argument to all functions marked with replicated
decorator. See the docs.
Also when you call them with sync=true
arguments - they will wait commit automatically. You can instead call them with callback=yourFunc
and you will receive a callback as soon as operation committed.
OK, excellent 😄 Is there any documentation on what gets passed to the result argument of the callback function?
It gets two arguments. First one is what your function returns (None
if nothing). And the second one - fail reason enum.
I took me a while to understand this even though the documentation does match what is supposed to happen. Thanks for the feedback. I've only just been able to take another look at pysyncobj
after all this time.