Copyright © (C) 2016, Project-FiFo UG
Authors: Heinz Nikolaus Gies (heinz@project-fifo.net).
Simple event store using flat files and mostly ordered storage. All operations are sequential, there is as most one seek for reads.
We achive this by keeping data in two files, for once the main store. It allows for events to be slightly out of order given a certain grace period. Evetns falling beyond that grace period are placed in a reconsiliation file.
The tradeoff here is that during reads the reconciliation file will be fully consumed. This is OK under the assumption that most events will be arrive mostly ordered.
In the future we will need to look into compaction when the recon file grows too big. Another option to deal with it would be to actively drop events that are too far out of order.
The file structure is suposed to be simle. Both the recon and the man event store file follow this guids:| 4 | 8 | 4 | Size | | Size | Time | ID | Data |The index file is prefixed with:
| 2 | 8 | | Version | Grace Period |Index data is then encoded as following (using second precision):
| 8 | 8 | 4 | | Time | Position | ID |
abstract datatype: efile()
event() = {pos_integer(), <<_:32>>, term()}
fold_fun() = fun((Time::pos_integer(), ID::<<_:32>>, Event::term(), AccIn::any()) -> AccOut::any())
opt() = {grace, pos_integer()} | no_index
append/2 | |
close/1 | |
count/1 | |
delete/1 | |
fold/3 | |
fold/5 | |
new/1 | |
new/2 | |
read/3 |
close(Efile::efile()) -> ok
delete(Name::efile() | string()) -> ok
fold(Fun::fold_fun(), Acc::any(), EFile::efile()) -> {ok, any(), efile()}
fold(Start::non_neg_integer(), End::pos_integer() | infinity, Fun::fold_fun(), Acc::any(), EFile::efile()) -> {ok, any(), efile()}
new(Name::string()) -> {ok, efile()}
Generated by EDoc, Sep 19 2016, 14:35:03.