-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
firestore: Implement Watch #4513
Comments
@schmidt-sebastian @dhermes I started working on some translation from js, but not really sure how everything interacts, and there are some event handlers that I'm not sure how to convert from js to python without knowing more of the code. But anyway, feel free to take a look and let me know if this is just way over my head or if you are willing to help me get through it. I also looked at the java code which is implemented a bit differently than js. Also this is just very preliminary work.... |
@dhermes But the question I have is how do I tell grpc to send the ListenResponse to the queue that I have? Also, would it be better to have one queue per Watch instance or one queue per system? Also seems to me that threads would be ok and I don't need multiprocessing? |
@chemelnucfin I'm not very familiar with the feature. To start, which RPC does watch correspond to? (The only BIDI RPCs are A basic implementation would like like this: import threading
import uuid
from six.moves import queue as queue_mod
from google.cloud import firestore
STOP = uuid.uuid4()
def make_request_gen(queue):
while True:
request = queue.get() # Blocks "forever"
if request == STOP:
break
yield request
def do_watch(queue, firestore_api):
request_gen = make_requent_gen(queue)
response_gen = firestore_api.listen(request_gen)
for response in response_gen:
do_something(response)
queue.put(STOP)
client = firestore.Client()
firestore_api = client._firestore_api
queue = queue_mod.Queue()
thread = threading.Thread(
target=do_watch, args=(queue, firestore_api), name='Meh')
thread.start()
I would leave it open so that users can specify which type of concurrency they want (with the above that would mean swapping out the queue and the thread for other primitives)
The
The I don't think you'd need a queue for the |
Yes, it corresponds to listen. So basically if I do the listen(request_gen), then grpc will send results into the queue whenever a change happens. ok, that's what I needed to know. thanks. |
No. The If you'd like to put them in a queue, that's where |
This is on the internal feature backlog. |
The Firestore Python client should gain the ability to receive realtime updates as outlined in the specification document.
Please take a look at Node: https://github.com/googleapis/nodejs-firestore/blob/master/src/watch.js
and Java: googleapis/google-cloud-java#2665
The text was updated successfully, but these errors were encountered: