Hi im currently looking into grpc and im curious about the use usage of a repeated field vs a stream. For example let's say i want to implement a reservation service for movie seats. The issue im facing is, that i want to inform the service for which movie i want to reserve the seats for. I can think of 2 solutions, first: I send the id of the movie with every seat i want to reserve, or with oneof at the beginning of the stream like this:
rpc ReserveSeatsForShowing(stream SeatReservationRequest) returns(Reservation);
message SeatReservationRequest{
oneof reservationOneOf{
int32 showingId = 1;
SeatReservation seatReservation = 2;
}
}
Or using a repeated field like this
rpc ReserveSeatsForShowing(SeatReservationRequest) returns(Reservation);
message SeatReservationRequest{
int32 showingId = 1;
repeated SeatReservation seatReservation = 2;
}
Since i haven't really worked with grpc before im not quite sure which option to choose or if other options are available.
Looking forward for your recommendations
oneof
. Meaning the first message in a stream is the request and as soon as the client sends a message the server responds with the nextn
messages – Torras