-
-
Notifications
You must be signed in to change notification settings - Fork 2
Stream data to export file #16
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
base: main
Are you sure you want to change the base?
Stream data to export file #16
Conversation
…gRequests, just a single add each call.
… it in PingRequestAgent.
… two decimal places - fix unit test error.
Codecov Report
@@ Coverage Diff @@
## main #16 +/- ##
===========================================
+ Coverage 30.76% 43.43% +12.66%
===========================================
Files 2 3 +1
Lines 65 99 +34
Branches 10 9 -1
===========================================
+ Hits 20 43 +23
- Misses 43 56 +13
+ Partials 2 0 -2
Continue to review full report at Codecov.
|
Just FYI - I haven't forgotten about this, just balancing a lot of plates at the moment. Will get back to this sometime this week. 🙂 |
np, i understand, I got a bit busy myself too. Thanks for the heads up.
…On Sun, Jun 26, 2022 at 12:07 PM James Turner ***@***.***> wrote:
Just FYI - I haven't forgotten about this, just balancing a lot of plates
at the moment. Will get back to this sometime this week. 🙂
—
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHGYXCPVHWDAAHIFUSUZUXDVQ63MVANCNFSM5WX3AJIQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
… to support single write file stream. Add stream flag to allow file share read access.
Hi @Turnerj , here is my latest version of single file stream writer. I have added a new command line switch (-e) as a flag to use a default export file path and name alongside the exe. I refactored the main workload into a "PerformPings" method so I could conditionally wrap the single stream around it. Go nuts and poke some holes in this , as I'm sure its terrible in more ways than one. Thanks |
I think we can flip the code around a bit - rather than trying to pass the exporting logic in, we instead make it listen on the same event we are pushing data out by. Basically when we know we want to export, we create a new instance of some exporter class that manages the file access and have it listen on our |
I can have a go at that..... |
So I have a new file exporter class and I have setup a method to listen to the |
Yeah, pretty much that. We make the file exporter disposable (with a using statement etc) and make that dispose of our steam when it disposes. |
@Turnerj working version using an event to conduct the export. |
|
||
if (options.ExportFileFullPath != null) | ||
{ | ||
var pingRequestFileExporter = new PingRequestFileExporter(options.ExportFileFullPath); | ||
pingRequestAgent.PingCompleted += pingRequestFileExporter.ExportSingleResultToFile; | ||
|
||
} | ||
|
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.
OK, I see why you had trouble trying to dispose of it. A quick-and-dirty workaround would be to declare PingRequestFileExporter? pingRequestFileExporter = null;
before the if-statement and then wrap the rest of the code in a try/finally. Then in the finally, we go pingRequestFileExporter?.Dispose();
.
For a more complete solution, it might be a more ground-up redesign of how the classes interact with each other so we don't even need the file exporter within the specific visual implementations.
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.
What I mean by the last part is that some of the difficulty is really just how the classes call each other. Ideal world would have something like each "layout" just register events rather than handle the life cycle itself. The ping session is kinda redundant now as we don't do anything with it. Remove the replication from the cancel key press etc logic in each layout.
If I were to name what I'm thinking, something like "pipelines". Each thing (a layout, exporting, etc) is just an item on the pipeline. I guess kinda like how the middleware works for ASP.NET Core but more around events than just calling a next();
action.
Please note this PR uses a branch based off the branch unit-testing also used in #15
I reworked the pingsession.cs to be stateful - it is only passed a single ping request.
Removed the need for a list of PingRequests.
Moved the PingRequestExportModel class into Pingalot.Core
Added Export File to the PingRequestOptions - maybe not the best idea but was the easiest to get the file details passed through to the PingRequestAgent.
Added the File Export function into PingRequestAgent - export a record at a time as it occurs.
Catered for an error with the export file path - if error then create file local to the exe with a generic name plus datetime.
Added a final ping stats method to pingstats to just pass in the end time.
The memory is now constant for the life of the program as we don't keep a list of ping requests.
Updated existing unit-tests to ensure all passing.