Engine Connector

Summary

The Engine Connector describes how clients connect to the engine API (Dendron API Server). It is used by Dendron CLI and Plugin Core.

Pseudocode

Initialization

../packages/engine-server/src/topics/connector.ts (Private)

EngineConnector.init(opts) {
    portOverride := opts

    if portOverride {
        @tryToConnect
        @initEngine
    } else {
        @createServerWatcher
    }
}

createServerWatcher {
    wsRoot := this

    port = getPortFilePath(wsRoot)

    while !@initialized {
        @connectAndInit
    }
}


connectAndInit {
    ...
    maybeEngine = @_connect
    if (maybeEngine)
        @initEngine
}

initEngine(opts) {
    port, engine := opts

    engine.sync
    @port = port
    @initialized = true
}


Backlinks