-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat 34 - save LDES Client state (#42)
* bump: bump dependency version * feat: update .gitignore to ignore .ldes folder * bump: bump dependency version * feat: switch from default type Readable to type EventStream * feat: export LDES Client EventStream state after end event * feat: move saveState and loadState to separate utils file * bump: bump dependency version * feat: start using type State from @treecg/actor-init-ldes-client * feat: use state in createReadStream when state present * bump: bump dependecy version * feat: react on now only syncing mode instead of end event and use LDES Client synchronization mode * feat: comment out the delete folder step * dist: new dist * feat: use .ldes/${options.storage}/state.json to save state * dist: new dist
- Loading branch information
1 parent
59251fb
commit eb15441
Showing
11 changed files
with
331 additions
and
191 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 |
---|---|---|
|
@@ -115,4 +115,7 @@ typings/ | |
.tern-port | ||
|
||
# Test output | ||
output/ | ||
output/ | ||
|
||
# LDES state folder | ||
.ldes/ |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs'; | ||
import type { State } from '@treecg/actor-init-ldes-client'; | ||
|
||
export const saveState = (state: State, storage: string): void => { | ||
const folder = `./.ldes/${storage}`; | ||
if (!existsSync(folder)) { | ||
mkdirSync(folder); | ||
} | ||
writeFileSync(`${folder}/state.json`, JSON.stringify(state)); | ||
}; | ||
|
||
export const loadState = (storage: string): State | null => { | ||
const folder = `./.ldes/${storage}`; | ||
if (existsSync(`${folder}/state.json`)) { | ||
return JSON.parse(readFileSync(`${folder}/state.json`).toString()); | ||
} | ||
return null; | ||
}; |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import type { Readable } from 'stream'; | ||
import type { EventStream } from '@treecg/actor-init-ldes-client'; | ||
import type { Member, Bucketizer } from '@treecg/types'; | ||
import type { Config } from '../Config'; | ||
|
||
interface Datasource { | ||
getData: (config: Config, bucketizer: Bucketizer) => Promise<Member[]>; | ||
getLinkedDataEventStream: (url: string) => Readable; | ||
getLinkedDataEventStream: (url: string, storage: string) => EventStream; | ||
} | ||
|
||
export default Datasource; |