What is the preference of streams? #3944
-
We are writing some bike renting system in which bikes send their location in a timely manner and the server can send commands to them. Looking thermostat sample which is very similar to our case, I noticed you are using a reading stream for getting instance temperature and publish to clients. If we use normal function call and use a server-side function and let bikes (devices) call the function to send their current location what gets wrong? I guess you are using a multiplexed TCP connection and assign a special single connection instance for each stream. Is there any other preference for using stream over using normal invokation? |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 3 replies
-
Hi Kamyar, That sounds pretty cool! If you let bikes (devices) send a regular request without streaming parameters each time they update their location, there's nothing inherently wrong with that approach. The thermostat example employs a "stream parameter" for the readings because it has less overhead—you're not creating a separate request for each reading. Streaming Approach:struct GpsLocation {
latitude: float64
longitude: float64
}
interface BikeStation {
UpdateBikeLocation(bikeId: int64, stream location: GpsLocation);
} With this approach, the bike device sends a request with its ID and then continuously streams its GPS coordinates to the bike station. Non-Streaming Approach:struct GpsLocation {
latitude: float64
longitude: float64
}
interface BikeStation {
UpdateBikeLocation(bikeId: int64, location: GpsLocation);
} Here, without the stream parameter, the bike device sends a request with both its ID and GPS coordinates each time it wants to update its location. For more details on "stream parameters", please refer to this guide. Additionally, the mapping of RPCs to streams is explained here. It's important to note that these are distinct concepts. Regards, |
Beta Was this translation helpful? Give feedback.
-
Another question: We are using some 3rd party bikes with a custom TCP socket protocol. We want to write an adapter to convert the protocol from/to IceRPC. We can either use just one connection to the server and multiplex all the bike requests into one (Using just one pipeline with a single proxy object) or we can create a separate connection (Pipeline+proxy) for each bike connection to the adapter. Which is the better choice? |
Beta Was this translation helpful? Give feedback.
Hi Kamyar,
That sounds pretty cool!
If you let bikes (devices) send a regular request without streaming parameters each time they update their location, there's nothing inherently wrong with that approach.
The thermostat example employs a "stream parameter" for the readings because it has less overhead—you're not creating a separate request for each reading.
Streaming Approach:
With this approach, the bike device sends a request with its ID and then continuously streams its GPS coordinates to the bike station.
Non-Streaming App…