Closed tirkarthi closed 6 years ago
I did an initial implementation of this. But it seems the watch callback is executed only once for the change since I was thinking about pub/sub like use cases.
Hi @tirkarthi :
While I appreciate the value of providing a callback based API in the library, I am not sure what the shape of this API should be.
In the meantime, would be be open to submitting a PR which implements a simple wrapper over the watch
function in the src/clj_fdb/transaction.clj
file? Let me know, and I will pick this up otherwise.
I did an initial implementation of this. But it seems the watch callback is executed only once for the change since I was thinking about pub/sub like use cases.
Yes, this is why I want to understand the possibilities before putting helper fns in the library.
Thanks @vedang for the review. I proposed it for API parity and initially it seemed to be a useful addition. But once I implemented it I couldn't fit a good use case for it. Maybe I am missing something about the use case since I am still a beginner with respect to FoundationDB.
Unfortunately, I will not be able to pick this up due to lack of time. I am closing this in favour of #11
Thanks
Is your feature request related to a problem? Please describe.
Implement watch API that can be used to track the changes made to a key.
Describe the solution you'd like
Watch API is available in the Java client that can be used to track the changes made to the key with callbacks.
Additional context
I have tried an initial implementation of
watch
that works as below :Implementation
https://github.com/tirkarthi/clj-foundationdb/blob/37f39adca4069070fab2a4630b76b4fab22ead93/src/clj_foundationdb/core.clj#L176
Basic test with callback and future
https://github.com/tirkarthi/clj-foundationdb/blob/37f39adca4069070fab2a4630b76b4fab22ead93/test/clj_foundationdb/core_test.clj#L305
Java docs reference
https://apple.github.io/foundationdb/javadoc/com/apple/foundationdb/Transaction.html#watch-byte:A-
Python docs reference with example
https://apple.github.io/foundationdb/developer-guide.html#watches
Feedback welcome.