How to watch using http api in python?

174 views
Skip to first unread message

Summer Wang

unread,
Nov 15, 2016, 11:03:32 PM11/15/16
to etcd-dev
No sure if it's the right place to ask. I want to make a python client using http api(there are too many dependencies using grpcio), tried several methods but seems all not work with grpc-gateway.

Do anybody have examples successfully watch etcdv3 using http api? thanks....

anthony...@coreos.com

unread,
Nov 16, 2016, 7:37:00 PM11/16/16
to etcd-dev
Hi,

The way to do it with curl (on key="foo") is:
curl http://localhost:2379/v3alpha/watch -X POST -d '{"create_request": {"key":"Zm9v"} }

However, it seems grpc-gateway will cancel the stream once the post request is completely sent; curl will exit before the watch receives any updates. I submitted a PR to grpc-gateway upstream with a potential fix.

Aleksandr Kuzminsky

unread,
Nov 16, 2016, 9:23:17 PM11/16/16
to etcd...@googlegroups.com

Sorry for offtopic, but what is it etcdv3 API and how is it different from https://coreos.com/etcd/docs/latest/api.html ?


On 11/15/16 8:03 PM, Summer Wang wrote:
No sure if it's the right place to ask. I want to make a python client using http api(there are too many dependencies using grpcio), tried several methods but seems all not work with grpc-gateway.

Do anybody have examples successfully watch etcdv3 using http api? thanks....
--
You received this message because you are subscribed to the Google Groups "etcd-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to etcd-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Aleksandr Kuzminsky
Phone: +1 (844) 533-0409 ext 101
Skype: aleksandr.kuzminsky
Web: https://twindb.com
Calendar: http://meetme.so/akuzminsky
signature.asc

anthony...@coreos.com

unread,
Nov 17, 2016, 12:33:16 PM11/17/16
to etcd-dev
That's the v2 API; it uses a json protocol. The v3 API is complete data model revamp (cf. https://coreos.com/etcd/docs/latest/dev-guide/api_reference_v3.html); it natively uses grpc but etcd also exposes a grpc gateway on `/v3alpha` to provide the grpc API through json requests as well. etcd 3.0.0 and newer supports both v2 and v3 APIs.

https://coreos.com/blog/etcd3-a-new-etcd.html gives an overview of the high-level differences.

tobias.o...@gmail.com

unread,
Jan 16, 2017, 4:06:08 PM1/16/17
to etcd-dev
It seems I am missing something important: the curl line below returns immediately (it doesn't sit and wait for a change).

I would have expected the HTTP/REST gateway of etcd3 to leave the HTTP/POST request "open" (similar to long-polling) - not?

I tried the latest release (3.0.16) and the current release candidate (3.1-rc1) - same behavior.

So how do I do a watch using curl and on etcd3 with the HTTP/REST gateway?

Ultimately, I want to access etcd3 from Python/Twisted - and I don't want to use gRPC for reasons.

Any hint would be greatly appreciated,

Cheers,
/Tobias

tobias.o...@gmail.com

unread,
Jan 16, 2017, 4:38:45 PM1/16/17
to etcd-dev
> However, it seems grpc-gateway will cancel the stream once the post request is completely sent; curl will exit before the watch receives any updates.

This one?

https://github.com/grpc-ecosystem/grpc-gateway/pull/262

Was closed without merging ..

How do I do a watch on etcd3 using curl? Can't get it working ..


Am Donnerstag, 17. November 2016 01:37:00 UTC+1 schrieb anthony...@coreos.com:

anthony...@coreos.com

unread,
Jan 17, 2017, 12:40:27 AM1/17/17
to etcd-dev
Hi,

This was fixed in 9a20743190a796b6e22184d88936dbe8ff7cb056 on November 17th. It's available in master will be included in the 3.1 release.

There is now also a grpc-gateway watch example included in the documentation: https://github.com/coreos/etcd/blob/master/Documentation/dev-guide/api_grpc_gateway.md

Tobias Oberstein

unread,
Jan 17, 2017, 2:35:31 AM1/17/17
to anthony...@coreos.com, etcd-dev
> This was fixed in 9a20743190a796b6e22184d88936dbe8ff7cb056 on November
> 17th. It's available in master will be included in the 3.1 release.

Ahh, thanks!

3.1-rc1 does NOT contain this commit .. I just built from master, and it
works. Thanks.

>
> There is now also a grpc-gateway watch example included in the
> documentation:
> https://github.com/coreos/etcd/blob/master/Documentation/dev-guide/api_grpc_gateway.md

Yeah, I trying that .. it might be worth having a note in this doc that
it requires etcd 3.1 release (or master). I lost like 2h trying and
wondering ..

Cheers,
/Tobias

Reply all
Reply to author
Forward
0 new messages