Skip to content

Commit

Permalink
feat: LdesDiskWriter processor to persist LDES as set of files on disk (
Browse files Browse the repository at this point in the history
#83)

* feat: LdesDiskWriter processor to persist LDES as set of files on disk

* test: Write tests for LdesDiskWriter processor

* ci: Run GH Actions using Node instead of Bun

* fix(deps): Mark `@esbuild/darwin-arm64` as optional dependency

* chore: Extract duplicate code into a function

* chore: Change to relative uri's to support any host location after LDES creation

* chore(deps): Update package-lock.json
  • Loading branch information
smessie authored Jan 23, 2025
1 parent f6d6c98 commit ccd0960
Show file tree
Hide file tree
Showing 12 changed files with 3,019 additions and 1,108 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Checkout
uses: actions/checkout@v3 # Checkout repo

- name: Setup Bun
uses: oven-sh/setup-bun@v1 # Setup bun
- name: Setup Node.js
uses: actions/setup-node@v3 # Setup node
with:
bun-version: latest
node-version: 22.x
cache: 'npm'

- run: bun i # Install dependencies
- run: bun run build # Build sources
- run: bun test # Run tests
- run: npm ci # Install dependencies
- run: npm run build # Build sources
- run: npm run test # Run tests
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,20 @@ This processor can be used to join multiple input streams or Reader Channels (`j

This a simple RDF data generator function used for testing. This processor will periodically generate RDF objects with 3 to 4 predicates.

### [`js:LdesDiskWriter`](https://github.com/rdf-connect/sds-processors/blob/master/configs/ldes_disk_writer.ttl#L8)

This processor can be used to transform an [SDS stream](https://w3id.org/sds/specification) and its correspondent stream of members into a LDES.
It will persist the LDES as a set of files on disk.

Alternative more advanced implementation: [sds-storage-writer-ts](https://github.com/rdf-connect/sds-storage-writer-ts) together with [LDES-Solid-Server](https://github.com/rdf-connect/LDES-Solid-Server).

An example of how to use this processor within a RDF-Connect pipeline definition is shown next:

```turtle
@prefix js: <https://w3id.org/conn/js#>.
[ ] a js:LdesDiskWriter;
js:dataInput <data/reader>;
js:metadataInput <metadata/reader>;
js:directory </tmp/ldes-disk/>.
```
49 changes: 49 additions & 0 deletions configs/ldes_disk_writer.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@prefix js: <https://w3id.org/conn/js#>.
@prefix fno: <https://w3id.org/function/ontology#>.
@prefix fnom: <https://w3id.org/function/vocabulary/mapping#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix : <https://w3id.org/conn#>.
@prefix sh: <http://www.w3.org/ns/shacl#>.

js:LdesDiskWriter a js:JsProcess;
js:file <../lib/ldesDiskWriter.js>;
js:function "ldesDiskWriter";
js:location <../>;
js:mapping [
a fno:Mapping;
fno:parameterMapping [
a fnom:PositionParameterMapping;
fnom:functionParameter "Data Input Channel";
fnom:implementationParameterPosition "0"^^xsd:int;
], [
a fnom:PositionParameterMapping;
fnom:functionParameter "Metadata Input Channel";
fnom:implementationParameterPosition "1"^^xsd:int;
], [
a fnom:PositionParameterMapping;
fnom:functionParameter "Directory";
fnom:implementationParameterPosition "2"^^xsd:int;
];
].

[ ] a sh:NodeShape;
sh:targetClass js:LdesDiskWriter;
sh:property [
sh:class :ReaderChannel;
sh:path js:dataInput;
sh:name "Data Input Channel";
sh:maxCount 1;
sh:minCount 1;
], [
sh:class :ReaderChannel;
sh:path js:metadataInput;
sh:name "Metadata Input Channel";
sh:maxCount 1;
sh:minCount 1;
], [
sh:datatype xsd:string;
sh:path js:directory;
sh:name "Directory";
sh:maxCount 1;
sh:minCount 1;
].
Loading

0 comments on commit ccd0960

Please sign in to comment.