-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
better error handling in http broadcasts ; remove blocking behavior from MoveNextAsync()
#119
base: main
Are you sure you want to change the base?
better error handling in http broadcasts ; remove blocking behavior from MoveNextAsync()
#119
Conversation
MoveNextAsync()
Thanks for raising these issues - rather than adding more retry/throttling logic into this library, I've added an example of how to do this in the HttpClient: https://github.com/saul/demofile-net/pull/122/files. I will most likely move forward with this approach rather than the implementation you did here - I believe you can achieve the same behaviour this way still. |
@@ -33,50 +33,104 @@ public HttpBroadcastReader(DemoParser<TGameParser> demo, HttpClient httpClient) | |||
_channel = Channel.CreateUnbounded<QueuedCommand>(); | |||
} | |||
|
|||
public BroadcastSyncDto? BroadcastSyncDto { get; private set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this in #122
/// <summary> | ||
/// The most recently received tick over the HTTP broadcast. | ||
/// </summary> | ||
public DemoTick BufferTailTick => new(Volatile.Read(ref _tailTick)); | ||
|
||
public int EnqueuedFragmentsCount => _channel.Reader.Count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this in #122
|
||
// Complete the Channel so that reader can be unblocked. | ||
// Note that exception is passed to the function, so reader will fail with same exception when trying to wait on empty Channel. | ||
_channel.Writer.Complete(ex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this in #122
That PR still doesn't solve the issue of blocking : |
This will prevent blocking in
MoveNextAsync()
, by callingWriter.Complete()
when exception happens, and will throw appropriate exception (the one from worker) when Channel becomes empty.So instead of blocking application for 10-15 seconds (like you suggested in other issue) when http broadcast has ended, you get the right exception immediately.
This PR also stops worker from entering infinite loop, when server starts returning 404 error for finished match.
Edit: removed blocking behavior from
MoveNextAsync()
, and added another methodWaitForAvailableDataAsync()
with same functionality