Created
April 21, 2020 16:52
-
-
Save kwilczynski/cbd40297f5591a99b4b8139126250958 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kwilczynski@ubuntu:~$ grpcurl kw-alpha4.us-east1.apps.lbcs.io:443 describe | |
com.example.myservice.MyService is a service: | |
service MyService { | |
rpc AddItem ( .com.example.myservice.MyAddItem ) returns ( .google.protobuf.Empty ) { | |
option (.google.api.http) = { post:"/state/{user_id}/items/add" body:"*" }; | |
} | |
rpc GetState ( .com.example.myservice.MyGetState ) returns ( .com.example.myservice.MyState ) { | |
option (.google.api.http) = { get:"/state/{user_id}" additional_bindings:<get:"/state/{user_id}/items" response_body:"items" > }; | |
} | |
rpc RemoveItem ( .com.example.myservice.MyRemoveItem ) returns ( .google.protobuf.Empty ) { | |
option (.google.api.http) = { post:"/state/{user_id}/items/{id}/remove" }; | |
} | |
} | |
kwilczynski@ubuntu:~$ curl -v https://kw-alpha4.us-east1.apps.lbcs.io/state/test/items/add -XPOST -d '{"user_id":"test", "id":"carrot", "name":"A carrot for Doom Guy bunny!", quantity: 1}' -H "Content-Type:application/json" | |
Note: Unnecessary use of -X or --request, POST is already inferred. | |
* Trying 34.74.64.5... | |
* TCP_NODELAY set | |
* Connected to kw-alpha4.us-east1.apps.lbcs.io (34.74.64.5) port 443 (#0) | |
* ALPN, offering h2 | |
* ALPN, offering http/1.1 | |
* successfully set certificate verify locations: | |
* CAfile: /etc/ssl/certs/ca-certificates.crt | |
CApath: /etc/ssl/certs | |
* TLSv1.3 (OUT), TLS handshake, Client hello (1): | |
* TLSv1.3 (IN), TLS handshake, Server hello (2): | |
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22): | |
* TLSv1.3 (IN), TLS handshake, Unknown (8): | |
* TLSv1.3 (IN), TLS handshake, Certificate (11): | |
* TLSv1.3 (IN), TLS handshake, CERT verify (15): | |
* TLSv1.3 (IN), TLS handshake, Finished (20): | |
* TLSv1.3 (OUT), TLS change cipher, Client hello (1): | |
* TLSv1.3 (OUT), TLS Unknown, Certificate Status (22): | |
* TLSv1.3 (OUT), TLS handshake, Finished (20): | |
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 | |
* ALPN, server accepted to use h2 | |
* Server certificate: | |
* subject: CN=us-east1.apps.lbcs.io | |
* start date: Mar 30 21:48:45 2020 GMT | |
* expire date: Jun 28 21:48:45 2020 GMT | |
* subjectAltName: host "kw-alpha4.us-east1.apps.lbcs.io" matched cert's "*.us-east1.apps.lbcs.io" | |
* issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3 | |
* SSL certificate verify ok. | |
* Using HTTP2, server supports multi-use | |
* Connection state changed (HTTP/2 confirmed) | |
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 | |
* TLSv1.3 (OUT), TLS Unknown, Unknown (23): | |
* TLSv1.3 (OUT), TLS Unknown, Unknown (23): | |
* TLSv1.3 (OUT), TLS Unknown, Unknown (23): | |
* Using Stream ID: 1 (easy handle 0x55c2114ab580) | |
* TLSv1.3 (OUT), TLS Unknown, Unknown (23): | |
> POST /state/test/items/add HTTP/2 | |
> Host: kw-alpha4.us-east1.apps.lbcs.io | |
> User-Agent: curl/7.58.0 | |
> Accept: */* | |
> Content-Type:application/json | |
> Content-Length: 85 | |
> | |
* TLSv1.3 (OUT), TLS Unknown, Unknown (23): | |
* We are completely uploaded and fine | |
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22): | |
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): | |
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): | |
* TLSv1.3 (IN), TLS Unknown, Unknown (23): | |
* Connection state changed (MAX_CONCURRENT_STREAMS updated)! | |
* TLSv1.3 (OUT), TLS Unknown, Unknown (23): | |
* TLSv1.3 (IN), TLS Unknown, Unknown (23): | |
< HTTP/2 200 | |
< content-type: application/json | |
< content-length: 2 | |
< grpc-encoding: identity | |
< date: Tue, 21 Apr 2020 16:51:12 GMT | |
< server: istio-envoy | |
< x-envoy-upstream-service-time: 186 | |
< | |
* TLSv1.3 (IN), TLS Unknown, Unknown (23): | |
* Connection #0 to host kw-alpha4.us-east1.apps.lbcs.io left intact | |
{}kwilczynski@ubuntu:~curl -v https://kw-alpha4.us-east1.apps.lbcs.io/state/test/items | |
* Trying 34.74.64.5... | |
* TCP_NODELAY set | |
* Connected to kw-alpha4.us-east1.apps.lbcs.io (34.74.64.5) port 443 (#0) | |
* ALPN, offering h2 | |
* ALPN, offering http/1.1 | |
* successfully set certificate verify locations: | |
* CAfile: /etc/ssl/certs/ca-certificates.crt | |
CApath: /etc/ssl/certs | |
* TLSv1.3 (OUT), TLS handshake, Client hello (1): | |
* TLSv1.3 (IN), TLS handshake, Server hello (2): | |
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22): | |
* TLSv1.3 (IN), TLS handshake, Unknown (8): | |
* TLSv1.3 (IN), TLS handshake, Certificate (11): | |
* TLSv1.3 (IN), TLS handshake, CERT verify (15): | |
* TLSv1.3 (IN), TLS handshake, Finished (20): | |
* TLSv1.3 (OUT), TLS change cipher, Client hello (1): | |
* TLSv1.3 (OUT), TLS Unknown, Certificate Status (22): | |
* TLSv1.3 (OUT), TLS handshake, Finished (20): | |
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 | |
* ALPN, server accepted to use h2 | |
* Server certificate: | |
* subject: CN=us-east1.apps.lbcs.io | |
* start date: Mar 30 21:48:45 2020 GMT | |
* expire date: Jun 28 21:48:45 2020 GMT | |
* subjectAltName: host "kw-alpha4.us-east1.apps.lbcs.io" matched cert's "*.us-east1.apps.lbcs.io" | |
* issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3 | |
* SSL certificate verify ok. | |
* Using HTTP2, server supports multi-use | |
* Connection state changed (HTTP/2 confirmed) | |
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 | |
* TLSv1.3 (OUT), TLS Unknown, Unknown (23): | |
* TLSv1.3 (OUT), TLS Unknown, Unknown (23): | |
* TLSv1.3 (OUT), TLS Unknown, Unknown (23): | |
* Using Stream ID: 1 (easy handle 0x556b74df3580) | |
* TLSv1.3 (OUT), TLS Unknown, Unknown (23): | |
> GET /state/test/items HTTP/2 | |
> Host: kw-alpha4.us-east1.apps.lbcs.io | |
> User-Agent: curl/7.58.0 | |
> Accept: */* | |
> | |
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22): | |
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): | |
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): | |
* TLSv1.3 (IN), TLS Unknown, Unknown (23): | |
* Connection state changed (MAX_CONCURRENT_STREAMS updated)! | |
* TLSv1.3 (OUT), TLS Unknown, Unknown (23): | |
* TLSv1.3 (IN), TLS Unknown, Unknown (23): | |
< HTTP/2 200 | |
< content-type: application/json | |
< content-length: 70 | |
< grpc-encoding: identity | |
< date: Tue, 21 Apr 2020 16:51:19 GMT | |
< server: istio-envoy | |
< x-envoy-upstream-service-time: 16 | |
< | |
* Connection #0 to host kw-alpha4.us-east1.apps.lbcs.io left intact | |
[{"id":"carrot","name":"A carrot for Doom Guy bunny!","quantity":2.0}]kwilczynski@ubuntu:~$ curl -v https://kw-alpha4.us-east1.apps.lbcs.io/state/test/items/add -XPOST -d '{"user_id":"test", "id":"carrot", "name":"A carrot for Doom Guy bunny!", quantity: 1}' -H "Content-Type:application/json" kubectl logs my-service-857b657f-nxmbv user-function | |
> [email protected] start-no-prestart /opt/cloudstateservice | |
> node index.js | |
gRPC server started on 0.0.0.0:8080 | |
getState MyState { items: [] } | |
addItem MyAddItem { | |
userId: 'test', | |
id: 'carrot', | |
name: 'A carrot for Doom Guy bunny!', | |
quantity: 1 } | |
addItem::emit event MyItemAdded { | |
item: | |
{ id: 'carrot', | |
name: 'A carrot for Doom Guy bunny!', | |
quantity: 1 } } | |
itemAdded | |
itemAdded::push | |
return state | |
getState MyState { | |
items: | |
[ MyItem { | |
id: 'carrot', | |
name: 'A carrot for Doom Guy bunny!', | |
quantity: 1 } ] } | |
itemAdded | |
itemAdded::push | |
return state | |
addItem MyAddItem { | |
userId: 'test', | |
id: 'carrot', | |
name: 'A carrot for Doom Guy bunny!', | |
quantity: 1 } | |
addItem::emit event MyItemAdded { | |
item: | |
{ id: 'carrot', | |
name: 'A carrot for Doom Guy bunny!', | |
quantity: 1 } } | |
itemAdded | |
itemAdded::return existing | |
return state | |
getState MyState { | |
items: | |
[ MyItem { | |
id: 'carrot', | |
name: 'A carrot for Doom Guy bunny!', | |
quantity: 2 } ] } | |
kwilczynski@ubuntu:~$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment