From the course: gRPC in Python

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Defining a streaming end point

Defining a streaming end point

From the course: gRPC in Python

Defining a streaming end point

- Let's define a streaming service. In our case, the car is going to stream the location into the server. Let's have a look. So, we add a track request, which has the car ID, the time, and the location, and a response, which has the count of how many requests were made. In the service, we now define the RPC truck, and we see it has a stream of truck requests, and it's going to return a truck response. It's going to return it when we close the connection. End of streaming. So let's run the generate, and let's have a look at the generated code. So, in the generated code now, we see that the right stub has a truck which is a stream unary meaning stream from the client to the server and gets a unary, a single response. On the service side, we see now that the server has a track method that gets a request iterator. It's an iterator that you can run a follow up getting one message after the other.

Contents