path-data
path-data copied to clipboard
Use `RetryPolicy` to keep SignalR connection alive and replace `List<RealtimeData>` with `ImmutableList<RealtimeData>`
This change can potentially fix high error rate of realtime endpoint.
closes: https://github.com/mrazza/path-data/issues/23
Other than the added logs that will help with future debugging, there are 2 problems this PR would solve:
- The reconnection is now handled by
RetryPolicy
, which should avoid the need to listen to theClosed
event. - Using
ImmutableList
withConcurrentDictionary
should help with the potential concurrency issues, asaddValueFactory
may be called multiple times, see link.
There are 2 problems this PR would not solve for now:
- It seems reading from
ConcurrentDictionary
usingGetRealtimeData
method is sometimes not very performant, it maybe due to GRPC server itself but I need more time to investigate, the GRPC connection simply stuck and can take long enough for the gateway to timeout the connection. - It seems using
ConcurrentDictionary
to storeHubConnection
suffer from similar issue as the problem mentioned above, asaddValueFactory
may be called multiple times however since it is not used as often as theConcurrentDictionary
used to storeList<RealtimeData>
I never observed any problem in production.
There are 1 problem I have no clue how to solve:
- It seems PATH sometimes simply don't feed messages for trains to a certain direction for a certain station, see a screenshot from official app for evidence. This result in trains missing from
upcomingTrains
array.
Recent monitoring from my own instance: Seems to be relatively stable after the changes.