Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise journal #36

Merged
merged 5 commits into from
Jul 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compliance/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ function errorHandler(message) {
}

function sendError(requestId, err) {
LOG.error(err);
return send(requestId, 'error', { err: `${err}` });
}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"build-quick": "tsc",
"build": "npm run clean && jest --silent && tsc && npm run doc",
"dev": "jest --watch --silent",
"dev+log": "jest --watch",
"compliance": "node compliance/test.js",
"prepublishOnly": "npm run build && npm version $VERSION && git push",
"doc": "npm pack && mv m-ld*.tgz doc/media/m-ld.tgz && dts-bundle-generator -o tmp.d.ts dist/index.d.ts --no-check && typedoc --options typedoc.js tmp.d.ts && rm tmp.d.ts",
Expand All @@ -29,7 +30,7 @@
},
"homepage": "https://github.com/m-ld/m-ld-js#readme",
"devDependencies": {
"@m-ld/m-ld-spec": "^0.3.1",
"@m-ld/m-ld-spec": "^0.3.2",
"@m-ld/typedoc-theme": "^0.1.0",
"@types/jest": "^26.0.0",
"@types/memdown": "^3.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/PubsubRemotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,18 @@ export abstract class PubsubRemotes extends AbstractMeld implements MeldRemotes
private produce<T>(data: Observable<T>, subAddress: string,
datumToJson: (datum: T) => Promise<object> | T, type: string) {
const notifier = this.notifier(subAddress);
const notify = async (notification: JsonNotification) => {
const notify = (notification: JsonNotification) => {
if (notification.error)
this.log.warn('Notifying error on', subAddress, notification.error);
else if (notification.complete)
this.log.debug('Completed production of', type);
await notifier.publish(notification)
notifier.publish(notification)
// If notifications fail due to MQTT death, the recipient will find out
// from the broker so here we make best efforts to notify an error and
// then give up.
.catch((error: any) => notifier.publish({ error: toJson(error) }))
.catch(this.warnError);
}
};
return data.pipe(
// concatMap guarantees delivery ordering despite toJson promise ordering
concatMap(async datum => await datumToJson(datum)),
Expand Down
3 changes: 1 addition & 2 deletions src/dataset/DatasetClone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { TreeClockMessageService } from '../messages';
import { Dataset } from '.';
import {
publishReplay, refCount, filter, ignoreElements, takeUntil, tap,
isEmpty, finalize, flatMap, toArray, first, map, debounceTime, distinctUntilChanged, scan, takeWhile
} from 'rxjs/operators';
isEmpty, finalize, flatMap, toArray, first, map, debounceTime, distinctUntilChanged, scan} from 'rxjs/operators';
import { delayUntil, Future, tapComplete, tapCount, SharableLock } from '../util';
import { levels } from 'loglevel';
import { MeldError } from '../m-ld/MeldError';
Expand Down
6 changes: 3 additions & 3 deletions src/dataset/JrqlGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ export class JrqlGraph {
}
}

async describe1<T extends Subject>(describe: Iri, context: Context = this.defaultContext): Promise<T> {
return this.describe(describe, undefined, context).pipe(first<T>()).toPromise();
async describe1<T>(describe: Iri, context: Context = this.defaultContext): Promise<T> {
return this.describe(describe, undefined, context).pipe(first<T & Subject>()).toPromise();
}

async find1<T extends Subject>(jrqlPattern: Partial<T>,
async find1<T>(jrqlPattern: Partial<T> & Subject,
context: Context = jrqlPattern['@context'] ?? this.defaultContext): Promise<Iri | ''> {
const quads = await this.findQuads(jrqlPattern, context);
return quads.length ? quads.map(quad => quad.subject.value)
Expand Down
Loading