[Server] Implement async transportlistener callback#3184
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the OPC UA transport layer to replace the Begin/End async callback pattern with the modern Task-based Async Pattern (TAP). The change eliminates the need for paired Begin/End methods and simplifies async operations by returning Task objects directly.
- Replaces
BeginProcessRequest/EndProcessRequestpattern withProcessRequestAsyncreturningTask<IServiceResponse> - Updates transport listeners to use async/await pattern instead of callback-based processing
- Removes synchronous processing path and large sections of deprecated thread scheduler code
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| ITransportListenerCallback.cs | Updates interface to use async pattern with cancellation token support |
| TcpTransportListener.cs | Refactors request handling to use async/await and removes callback completion method |
| ServerBase.cs | Removes deprecated thread scheduler code and updates async request processing |
| IServerBase.cs | Updates interface signature to include cancellation token |
| IEndpointBase.cs | Replaces Begin/End pattern with async method returning Task |
| EndpointBase.cs | Implements new async pattern and adds EndpointIncomingRequest class |
| HttpsTransportListener.cs | Updates to use new async callback pattern |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| using CancellationTokenSource timeoutHintCts = timeoutHint > 0 ? | ||
| new CancellationTokenSource(timeoutHint) | ||
| : new CancellationTokenSource(); |
There was a problem hiding this comment.
Creating a CancellationTokenSource when timeoutHint is 0 or negative is unnecessary. Consider only creating it when timeoutHint > 0 and using CancellationToken.None otherwise.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3184 +/- ##
==========================================
- Coverage 58.03% 57.58% -0.46%
==========================================
Files 356 354 -2
Lines 78102 78120 +18
Branches 13817 13823 +6
==========================================
- Hits 45330 44984 -346
- Misses 28599 28907 +308
- Partials 4173 4229 +56 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Proposed changes
Get rid of Begin/End async callback in ITransportlistenerCallback & IEndpointBase and instead use TAP async pattern.
Related Issues
Types of changes
Checklist
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...