forked from RolandPheasant/TailBlazer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
481e75d
commit 655fb3f
Showing
9 changed files
with
84 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.IO; | ||
using System.Reactive.Concurrency; | ||
using System.Reactive.Linq; | ||
using TailBlazer.Domain.Ratings; | ||
|
||
|
||
namespace TailBlazer.Domain.FileHandling.New | ||
{ | ||
|
||
|
||
public class FileIndexer | ||
{ | ||
/* | ||
1. Get length - this gives extent. | ||
2. Calculate average line length - gives position to scroll to | ||
3. Segment files?? | ||
*/ | ||
|
||
/* | ||
1. Grab segments and load observable list | ||
2. [Clear segments when file is missing or size has reduced] | ||
3. From segments, we require index - use transform function | ||
4. Load details of last segment first | ||
5. Load latest page on tail - max 1 Mb [always keep in memory] | ||
*/ | ||
|
||
public FileIndexer() | ||
{ | ||
} | ||
} | ||
|
||
public class FileMonitor | ||
{ | ||
|
||
|
||
public FileMonitor(string fullPath, IRatingService ratingsMetrics, IScheduler scheduler = null) | ||
{ | ||
if (fullPath == null) throw new ArgumentNullException(nameof(fullPath)); | ||
if (ratingsMetrics == null) throw new ArgumentNullException(nameof(ratingsMetrics)); | ||
|
||
scheduler = scheduler ?? Scheduler.Default; | ||
|
||
var fileInfo = new FileInfo(fullPath); | ||
|
||
var refreshRate = ratingsMetrics.Metrics.Take(1) | ||
.Select(metrics => TimeSpan.FromMilliseconds(metrics.RefreshRate)) | ||
.Wait(); | ||
|
||
var fileChanged = fileInfo | ||
.WatchFile(scheduler: scheduler, refreshPeriod: refreshRate); | ||
|
||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters