Skip to content

Commit 8a925b1

Browse files
Merge pull request #49 from SolidLabResearch/refactor/rename-to-heimdall
Rename Solid Stream Aggregator to Heimdall
2 parents f4f1eed + c06b8c3 commit 8a925b1

47 files changed

Lines changed: 528 additions & 209 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# Solid Stream Aggregator
1+
# Heimdall
22

3-
<img src="./solid-stream-aggregator.webp" alt="Logo" width="150">
4-
5-
The Solid Stream Aggregator is a service which can be used on top of one or multiple Solid Pods and constructs a materialized view on top of the stream measurements stored in the Solid Pod. The Solid Stream Aggregator currently functions under the assumptions that the Solid Pod uses the [LDES in LDP](https://woutslabbinck.github.io/LDESinLDP/) specification to store the stream measrements. The aggregated results are sent to the client requesting the data, as well as the materialized view was published to the Solid Stream Aggregator's Solid Pod for further re-use by other clients, and processes which have similar requirements of the aggregated results.
3+
Heimdall, a Solid Stream Analytics Service, can be used on top of one or multiple Solid Pods and constructs a materialized view on top of the stream measurements stored in the Solid Pod. Heimdall currently functions under the assumption that the Solid Pod uses the [LDES in LDP](https://woutslabbinck.github.io/LDESinLDP/) specification to store the stream measurements. The aggregated results are sent to the client requesting the data, and the materialized view is published to Heimdall's Solid Pod for further reuse by other clients and processes with similar aggregated-result requirements.
64

75
## Requirements
86

@@ -12,39 +10,39 @@ The Solid Stream Aggregator is a service which can be used on top of one or mult
1210

1311
## Configuration of the Solid Pod
1412

15-
- We are under the assumption that the client queries the solid pod using the solid stream aggregator, however the client does not know the location of the LDES Stream by default.
16-
We employ [Type Indexes](https://solid.github.io/type-indexes/) to store the location of one or more LDES streams. When querying the Solid Pod, the aggregator first queries the Type Index to get the location of the LDES stream and then retrieves the LDES stream to get the sensor events.
13+
- We are under the assumption that the client queries the Solid Pod using Heimdall, but the client does not know the location of the LDES stream by default.
14+
We employ [Type Indexes](https://solid.github.io/type-indexes/) to store the location of one or more LDES streams. When querying the Solid Pod, Heimdall first queries the Type Index to get the location of the LDES stream and then retrieves the LDES stream to get the sensor events.
1715

1816
## Installation
1917

2018
- Clone the repository
2119
- Install the dependencies using `npm install`
22-
- Start the Solid Stream Aggregator's Solid Pod with the command
20+
- Start Heimdall's Solid Pod with the command
2321
```bash
2422
npm run start-solid-server
2523
```
26-
The command will start a Solid Server on the port 3000 with a Solid Pod named `aggregation_pod` which can be accessed at `http://localhost:3000/aggregation_pod/`. The aggregation results are stored in the aggregator's Solid Pod in form of the LDES stream using the [LDES in LDP](https://woutslabbinck.github.io/LDESinLDP/) specification.
27-
- Create a folder and a file named `logs/aggregation.log` in the root directory of the project. The logs of the Solid Stream Aggregator are stored in this file.
28-
- Now, start the Solid Stream Aggregator with the command
24+
The command will start a Solid Server on the port 3000 with a Solid Pod named `aggregation_pod` which can be accessed at `http://localhost:3000/aggregation_pod/`. The aggregation results are stored in Heimdall's Solid Pod in the form of an LDES stream using the [LDES in LDP](https://woutslabbinck.github.io/LDESinLDP/) specification.
25+
- Create a folder and a file named `logs/aggregation.log` in the root directory of the project. Heimdall stores its logs in this file.
26+
- Now, start Heimdall with the command
2927
```bash
3028
npm run start aggregation
3129
```
32-
The command will start the Solid Stream Aggregator on the port 8080. The Solid Stream Aggregator exposes a HTTP as well as a WebSocket server at the port 8080 where the client can send a request for aggregated results from a Solid Pod.
30+
The command will start Heimdall on port 8080. Heimdall exposes both an HTTP server and a WebSocket server on port 8080 where the client can send a request for aggregated results from a Solid Pod.
3331

34-
- The protocol to communicate to the Solid Stream Aggregator is by sending a RSP-QL query to the Aggregator.
32+
- The protocol to communicate with Heimdall is by sending a RSP-QL query to the service.
3533
```ts
3634
let message = {
37-
// The query to be sent to the Solid Stream Aggregator (RSP-QL query)
35+
// The query to be sent to Heimdall (RSP-QL query)
3836
query: `INSERT YOUR QUERY HERE`,
3937
// The type of mointoring query can be either, `historical+live` or `live`
4038
type: `INSERT YOUR TYPE HERE`
4139
}
4240
```
43-
and send this message object to the aggregator using the WebSocket connection.
41+
and send this message object to Heimdall using the WebSocket connection.
4442

4543
## Tests
4644

47-
The tests for the Solid Stream Aggregator are written using the Jest framework. The coverage isn't 100% yet, but will be done in the recent future.
45+
The tests for Heimdall are written using the Jest framework. Coverage is not yet 100%.
4846

4947
## Linting
5048

jest.config.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,12 @@ module.exports = {
22
preset: 'ts-jest',
33
testEnvironment: 'node',
44
setupFiles: ['dotenv/config'],
5-
};
6-
5+
moduleNameMapper: {
6+
'^rsp-js$': '<rootDir>/src/test/rsp-js.ts',
7+
},
8+
testPathIgnorePatterns: [
9+
'/node_modules/',
10+
'<rootDir>/scripts/uma/test.ts',
11+
],
12+
};
13+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "solid-stream-aggregator",
33
"version": "1.0.0",
4-
"description": "Aggregation on top of streams generated from a Solid Pod",
4+
"description": "Heimdall, a Solid Stream Analytics Service built on top of streams generated from a Solid Pod",
55
"main": "dist/index.js",
66
"scripts": {
77
"start": "npx tsc && cp -r ./src/static ./dist && node --max-old-space-size=8192 dist/index.js ",
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
import { storeToString } from "@treecg/versionawareldesinldp";
22
const N3 = require('n3');
33
/**
4-
* Class for adding the aggregator to the solid pod's profile card.
5-
* @class AggregatorAbstraction
4+
* Class for adding Heimdall to the solid pod's profile card.
5+
* @class HeimdallAbstraction
66
*/
7-
export class AggregatorAbstraction {
7+
export class HeimdallAbstraction {
88
/**
99
*
10-
* A map of the solid pod URLs with the location of the aggregator.
10+
* A map of the solid pod URLs with the location of Heimdall.
1111
* @type {Map<string, string>}
12-
* @memberof AggregatorAbstraction
12+
* @memberof HeimdallAbstraction
1313
*/
14-
pod_aggregator_location: Map<string, string>;
14+
pod_heimdall_location: Map<string, string>;
1515
/**
16-
* Creates an instance of AggregatorAbstraction.
17-
* @param {Map<string, string>} aggregator_map - A map of the solid pod URLs with the location of the aggregator.
18-
* @memberof AggregatorAbstraction
16+
* Creates an instance of HeimdallAbstraction.
17+
* @param {Map<string, string>} heimdall_map - A map of the solid pod URLs with the location of Heimdall.
18+
* @memberof HeimdallAbstraction
1919
*/
20-
constructor(aggregator_map: Map<string, string>) {
21-
this.pod_aggregator_location = aggregator_map;
20+
constructor(heimdall_map: Map<string, string>) {
21+
this.pod_heimdall_location = heimdall_map;
2222
}
2323
/**
24-
* Adds the aggregator to the solid pod card.
25-
* @memberof AggregatorAbstraction
24+
* Adds Heimdall to the solid pod card.
25+
* @memberof HeimdallAbstraction
2626
*/
27-
public add_aggregator_to_pod_card() {
28-
this.pod_aggregator_location.forEach((pod_location: string, aggregator_location: string) => {
29-
this.patch_request(pod_location, aggregator_location);
27+
public add_heimdall_to_pod_card() {
28+
this.pod_heimdall_location.forEach((pod_location: string, heimdall_location: string) => {
29+
this.patch_request(pod_location, heimdall_location);
3030
});
3131
}
3232
/**
33-
* Patches the solid pod with the aggregator location.
33+
* Patches the solid pod with Heimdall's location.
3434
* @param {string} solid_pod_url - The URL of the solid pod.
35-
* @param {string} aggregator_location - The location of the aggregator.
36-
* @memberof AggregatorAbstraction
35+
* @param {string} heimdall_location - The location of Heimdall.
36+
* @memberof HeimdallAbstraction
3737
*/
38-
public patch_request(solid_pod_url: string, aggregator_location: string) {
38+
public patch_request(solid_pod_url: string, heimdall_location: string) {
3939
const store = new N3.Store();
4040
store.addQuad(
4141
N3.DataFactory.namedNode(solid_pod_url + '/profile/card#me'),
@@ -50,7 +50,7 @@ export class AggregatorAbstraction {
5050
store.addQuad(
5151
N3.DataFactory.namedNode('http://argahsuknesib.github.io/asdo/StreamAggregationService'),
5252
N3.DataFactory.namedNode('http://xmlns.com/foaf/0.1/webId'),
53-
N3.DataFactory.namedNode(aggregator_location + '/#this')
53+
N3.DataFactory.namedNode(heimdall_location + '/#this')
5454
);
5555
fetch(solid_pod_url, {
5656
method: 'PATCH',
@@ -60,4 +60,4 @@ export class AggregatorAbstraction {
6060
body: "INSERT DATA {" + storeToString(store) + "}",
6161
});
6262
}
63-
}
63+
}

src/config/aggregator_setup.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/config/heimdallConfig.test.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import {
2+
DEFAULT_HEIMDALL_HTTP_SERVER_URL,
3+
DEFAULT_HEIMDALL_RATE_LIMIT,
4+
DEFAULT_HEIMDALL_WS_SERVER_URL,
5+
resolveHeimdallRuntimeConfig,
6+
resolveHeimdallSetupConfig,
7+
} from './heimdallConfig';
8+
9+
describe('heimdall configuration compatibility', () => {
10+
it('prefers new setup keys when present', () => {
11+
expect(resolveHeimdallSetupConfig({
12+
heimdall_http_server_url: 'http://heimdall.example/http',
13+
heimdall_ws_server_url: 'ws://heimdall.example/ws',
14+
})).toEqual({
15+
heimdallHttpServerUrl: 'http://heimdall.example/http',
16+
heimdallWsServerUrl: 'ws://heimdall.example/ws',
17+
});
18+
});
19+
20+
it('falls back to legacy setup keys when the new keys are absent', () => {
21+
expect(resolveHeimdallSetupConfig({
22+
aggregator_http_server_url: 'http://legacy.example/http',
23+
aggregator_ws_server_url: 'ws://legacy.example/ws',
24+
})).toEqual({
25+
heimdallHttpServerUrl: 'http://legacy.example/http',
26+
heimdallWsServerUrl: 'ws://legacy.example/ws',
27+
});
28+
});
29+
30+
it('prefers new setup keys over legacy setup keys when both are present', () => {
31+
expect(resolveHeimdallSetupConfig({
32+
heimdall_http_server_url: 'http://heimdall.example/http',
33+
aggregator_http_server_url: 'http://legacy.example/http',
34+
heimdall_ws_server_url: 'ws://heimdall.example/ws',
35+
aggregator_ws_server_url: 'ws://legacy.example/ws',
36+
})).toEqual({
37+
heimdallHttpServerUrl: 'http://heimdall.example/http',
38+
heimdallWsServerUrl: 'ws://heimdall.example/ws',
39+
});
40+
});
41+
42+
it('preserves the current defaults when neither setup key exists', () => {
43+
expect(resolveHeimdallSetupConfig({})).toEqual({
44+
heimdallHttpServerUrl: DEFAULT_HEIMDALL_HTTP_SERVER_URL,
45+
heimdallWsServerUrl: DEFAULT_HEIMDALL_WS_SERVER_URL,
46+
});
47+
});
48+
49+
it('prefers the new runtime key when present', () => {
50+
expect(resolveHeimdallRuntimeConfig({
51+
aggregation_pod_ldes_location: 'http://localhost:3000/aggregation_pod/',
52+
heimdall_rate_limit: 15,
53+
})).toEqual({
54+
aggregationPodLdesLocation: 'http://localhost:3000/aggregation_pod/',
55+
heimdallRateLimit: 15,
56+
});
57+
});
58+
59+
it('falls back to the legacy runtime key when the new key is absent', () => {
60+
expect(resolveHeimdallRuntimeConfig({
61+
aggregation_pod_ldes_location: 'http://localhost:3000/aggregation_pod/',
62+
aggregator_rate_limit: 20,
63+
})).toEqual({
64+
aggregationPodLdesLocation: 'http://localhost:3000/aggregation_pod/',
65+
heimdallRateLimit: 20,
66+
});
67+
});
68+
69+
it('prefers the new runtime key over the legacy runtime key when both are present', () => {
70+
expect(resolveHeimdallRuntimeConfig({
71+
aggregation_pod_ldes_location: 'http://localhost:3000/aggregation_pod/',
72+
heimdall_rate_limit: 10,
73+
aggregator_rate_limit: 25,
74+
})).toEqual({
75+
aggregationPodLdesLocation: 'http://localhost:3000/aggregation_pod/',
76+
heimdallRateLimit: 10,
77+
});
78+
});
79+
80+
it('preserves the current runtime default when neither rate-limit key exists', () => {
81+
expect(resolveHeimdallRuntimeConfig({
82+
aggregation_pod_ldes_location: 'http://localhost:3000/aggregation_pod/',
83+
})).toEqual({
84+
aggregationPodLdesLocation: 'http://localhost:3000/aggregation_pod/',
85+
heimdallRateLimit: DEFAULT_HEIMDALL_RATE_LIMIT,
86+
});
87+
});
88+
});

src/config/heimdallConfig.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
export const DEFAULT_HEIMDALL_HTTP_SERVER_URL = 'http://n078-22.wall1.ilabt.imec.be:8080/';
2+
export const DEFAULT_HEIMDALL_WS_SERVER_URL = 'ws://n078-22.wall1.ilabt.imec.be:8080/';
3+
export const DEFAULT_HEIMDALL_RATE_LIMIT = 30;
4+
5+
export type HeimdallSetupConfig = {
6+
heimdall_http_server_url?: string;
7+
aggregator_http_server_url?: string;
8+
heimdall_ws_server_url?: string;
9+
aggregator_ws_server_url?: string;
10+
};
11+
12+
export type HeimdallRuntimeConfig = {
13+
aggregation_pod_ldes_location: string;
14+
heimdall_rate_limit?: number;
15+
aggregator_rate_limit?: number;
16+
};
17+
18+
export type ResolvedHeimdallSetupConfig = {
19+
heimdallHttpServerUrl: string;
20+
heimdallWsServerUrl: string;
21+
};
22+
23+
export type ResolvedHeimdallRuntimeConfig = {
24+
aggregationPodLdesLocation: string;
25+
heimdallRateLimit: number;
26+
};
27+
28+
/**
29+
* Resolve Heimdall setup URLs from new or legacy configuration keys.
30+
* @param {HeimdallSetupConfig} config - The raw setup configuration object.
31+
* @returns {ResolvedHeimdallSetupConfig} The normalized setup configuration.
32+
*/
33+
export function resolveHeimdallSetupConfig(config: HeimdallSetupConfig): ResolvedHeimdallSetupConfig {
34+
return {
35+
heimdallHttpServerUrl:
36+
config.heimdall_http_server_url ??
37+
config.aggregator_http_server_url ??
38+
DEFAULT_HEIMDALL_HTTP_SERVER_URL,
39+
heimdallWsServerUrl:
40+
config.heimdall_ws_server_url ??
41+
config.aggregator_ws_server_url ??
42+
DEFAULT_HEIMDALL_WS_SERVER_URL,
43+
};
44+
}
45+
46+
/**
47+
* Resolve Heimdall runtime settings from new or legacy configuration keys.
48+
* @param {HeimdallRuntimeConfig} config - The raw runtime configuration object.
49+
* @returns {ResolvedHeimdallRuntimeConfig} The normalized runtime configuration.
50+
*/
51+
export function resolveHeimdallRuntimeConfig(config: HeimdallRuntimeConfig): ResolvedHeimdallRuntimeConfig {
52+
return {
53+
aggregationPodLdesLocation: config.aggregation_pod_ldes_location,
54+
heimdallRateLimit:
55+
config.heimdall_rate_limit ??
56+
config.aggregator_rate_limit ??
57+
DEFAULT_HEIMDALL_RATE_LIMIT,
58+
};
59+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"aggregation_pod_ldes_location" : "http://localhost:3000/aggregation_pod/",
3-
"aggregator_rate_limit": 30
4-
}
3+
"heimdall_rate_limit": 30
4+
}

src/config/heimdall_setup.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"heimdall_http_server_url": "http://n078-22.wall1.ilabt.imec.be:8080/",
3+
"heimdall_ws_server_url": "ws://n078-22.wall1.ilabt.imec.be:8080/"
4+
}

0 commit comments

Comments
 (0)