# HG changeset patch # User drewp@bigasterisk.com # Date 2023-05-29 20:22:44 # Node ID b51c74da9d3556631d174a4e931e5f68becb91e3 # Parent cd4a9eeeb9e6b3cc76d57a07c5ead79e9bfc7cce more cleanup- mixed up with other commits diff --git a/light9/web/AutoDependencies.ts b/light9/web/AutoDependencies.ts --- a/light9/web/AutoDependencies.ts +++ b/light9/web/AutoDependencies.ts @@ -2,16 +2,11 @@ import debug from "debug"; import { NamedNode, Quad_Graph, Quad_Object, Quad_Predicate, Quad_Subject, Term, Util } from "n3"; import { filter } from "underscore"; import { Patch, QuadPattern } from "./patch"; +import { SubEvent } from "sub-events"; +import { SyncedGraph } from "./SyncedGraph"; const log = debug("autodep"); -interface QuadPattern { - subject: Quad_Subject | null; - predicate: Quad_Predicate | null; - object: Quad_Object | null; - graph: Quad_Graph | null; -} - // use patch as an optional optimization, but you can't count on it export type HandlerFunc = (p?: Patch) => void; @@ -28,7 +23,8 @@ class Handler { export class AutoDependencies { handlers: Handler; handlerStack: Handler[]; - constructor() { + graphError: SubEvent = new SubEvent(); + constructor(private graph: SyncedGraph) { // tree of all known Handlers (at least those with non-empty // patterns). Top node is not a handler. this.handlers = new Handler(null, "root"); @@ -75,6 +71,7 @@ export class AutoDependencies { this.handlerStack.pop(); } } + // handler might have no watches, in which case we could forget about it logHandlerTree() { log("handler tree:"); diff --git a/light9/web/RdfdbSyncedGraph.ts b/light9/web/RdfdbSyncedGraph.ts --- a/light9/web/RdfdbSyncedGraph.ts +++ b/light9/web/RdfdbSyncedGraph.ts @@ -33,6 +33,7 @@ export class RdfdbSyncedGraph extends Li const prefixes = new Map([ ["", "http://light9.bigasterisk.com/"], ["dev", "http://light9.bigasterisk.com/device/"], + ["effect", "http://light9.bigasterisk.com/effect/"], ["rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"], ["rdfs", "http://www.w3.org/2000/01/rdf-schema#"], ["xsd", "http://www.w3.org/2001/XMLSchema#"], diff --git a/light9/web/SyncedGraph.ts b/light9/web/SyncedGraph.ts --- a/light9/web/SyncedGraph.ts +++ b/light9/web/SyncedGraph.ts @@ -36,6 +36,10 @@ export class SyncedGraph { this.prefixFuncs = this.rebuildPrefixFuncs(prefixes); this.graph = new N3.Store(); this.autoDeps = new AutoDependencies(this); + this.autoDeps.graphError.subscribe((e) => { + log("graph learned of error - reconnecting", e); + this.client.disconnect(); + }); this.clearGraph(); this.client = new RdfDbClient(patchSenderUrl, this._clearGraphOnNewConnection.bind(this), this._applyPatch.bind(this), this.setStatus);