- Repository structure based on this!
- Program is located in
/cmd/fareestimate/main.go
- program starts by initiating
/pkg/config/config.go
package that sets program wide default vars as well as accepts command line argumens to override defaults. Rungo run cmd/fareestimate/main.go -help
to see all available options. - program gets pointer to fare calculator. It's used for calculating fares based on time of the day and distance gained between 2 points. It also keeps track of total ride fare and able to produce csv friendly representation of this data.
- it then gets data stream window
streamwindow.New()
. This is a 2 slot moving window that will be accepting data from input file stream. It will act as filter and decorator, ensuring invalid data does not pass through it and 2 different rides don't get mixed up. It returns valid pair of 2 enriched points. - programs starts reading file line by line using bufio scanner so that host machine does not run out of memory when processing large files. Process starts in separate routine and accepts channel over which it's going to send file data. Process
csv row -> []string{} -> PointInTime{} -> filter -> fare calculator -> report
. One ride can have millions of points in csv file but in fare calculator it's going to be represented by single key/value pair. So it's memory efficient and safe. - reading is done, program get's valid fares, transforms them into csv friendly input and generates report file.
- run tests from root folder
go test ./...
-
Notifications
You must be signed in to change notification settings - Fork 0
Daniel1984/fare-estimate
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published