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

Remove DMS #253

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const { RESTv2 } = require('bfx-api-node-rest')
module.exports = async ({
bfxRestURL,
bfxWSURL,
bfxHostedWsUrl,
bfxMetricsWsUrl,
os,
releaseVersion,
Expand Down Expand Up @@ -58,7 +57,6 @@ module.exports = async ({
port: wsServerPort,
restURL: bfxRestURL,
wsURL: bfxWSURL,
hostedURL: bfxHostedWsUrl,
metricsServerURL: bfxMetricsWsUrl,
os,
releaseVersion,
Expand Down
6 changes: 0 additions & 6 deletions lib/ws_servers/api/algos/algo_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,6 @@ class AlgoWorker {
this.sendError(error)
})

this.host.on('meta:reload', async () => {
d('meta reloaded')
this.pub(['algo.reload'])
await this.sendActiveAlgosForAllModes(false)
})

this.host.on('ao:stopped', async (data) => {
const { mode } = this.settings
const [gid, serialized] = data
Expand Down
150 changes: 0 additions & 150 deletions lib/ws_servers/api/dms_remote_control.js

This file was deleted.

13 changes: 0 additions & 13 deletions lib/ws_servers/api/factories/create_dms_control.js

This file was deleted.

2 changes: 0 additions & 2 deletions lib/ws_servers/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ module.exports = class APIWSServer extends WSServer {
strategyExecutionDB,
restURL,
wsURL,
hostedURL,
metricsServerURL,
os,
releaseVersion,
Expand Down Expand Up @@ -144,7 +143,6 @@ module.exports = class APIWSServer extends WSServer {

this.wsURL = wsURL
this.restURL = restURL
this.hostedURL = hostedURL
this.metricsServerURL = metricsServerURL
this.os = os
this.releaseVersion = releaseVersion
Expand Down
6 changes: 0 additions & 6 deletions lib/ws_servers/api/service_hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@ class ServiceHub {
constructor () {
this.client = null
this.algoWorker = null
this.dmsControl = null
this.strategyManager = null
this.metricsClient = null
}

async close () {
if (this.dmsControl) {
this.dmsControl.close()
this.dmsControl = null
}

if (this.client) {
this.client.close()
this.client = null
Expand Down
15 changes: 0 additions & 15 deletions lib/ws_servers/api/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ class Session {
return this.services[this.mode].algoWorker
}

/**
* @return {DmsRemoteControl|null}
*/
getDmsControl () {
if (!this.mode) return null
return this.services[this.mode].dmsControl
}

/**
* @return {StrategyManager|null}
*/
Expand Down Expand Up @@ -95,13 +87,6 @@ class Session {
this.services[this.mode].client = client
}

/**
* @param {DmsRemoteControl} dmsControl
*/
setDmsControl (dmsControl) {
this.services[this.mode].dmsControl = dmsControl
}

/**
* @param {AlgoWorker} algoWorker
*/
Expand Down
52 changes: 0 additions & 52 deletions lib/ws_servers/api/start_connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const _isString = require('lodash/isString')
const { DEFAULT_USER } = require('../../constants')
const createClient = require('./open_auth_bitfinex_connection')
const createAlgoWorker = require('./factories/create_algo_worker')
const createDmsControl = require('./factories/create_dms_control')
const createFilteredWs = require('./factories/created_filtered_ws')
const createStrategyManager = require('./factories/create_strategy_manager')
const createMetricsClient = require('./factories/create_metrics_client')
Expand Down Expand Up @@ -43,15 +42,13 @@ class ConnectionManager {
const settings = await getUserSettings(db)

const results = await Promise.allSettled([
this._startDmsControl(server, session, settings),
this._startAlgoWorker(server, session, wsForMode, settings, hasNewCredentials),
this._startStrategyManager(server, session, wsForMode, settings),
this._startBfxClient(server, session, wsForMode, settings, hasNewCredentials),
this._startMetricsClient(server, session, wsForMode, hasNewCredentials)
])

let status = {
dmsControl: false,
algoWorker: false,
bfxClient: false,
strategyManager: false,
Expand Down Expand Up @@ -85,42 +82,6 @@ class ConnectionManager {
return { hasNewCredentials }
}

/**
* @param {APIWSServer} server
* @param {Session} session
* @param {boolean} dms
* @param {string} dmsScope
* @returns {Promise<*>}
*/
async updateDms (server, session, dms, dmsScope) {
if (!dmsScope) {
return { dmsControl: false }
}

let dmsControl = session.getDmsControl()

if (dmsControl && dmsControl.isOpen) {
dmsControl.updateStatus(dms)
return { dmsControl: dms }
}

if (!dms) {
return { dmsControl: false }
}

dmsControl = createDmsControl(server)
session.setDmsControl(dmsControl)

const { apiKey, apiSecret } = this.credentials[session.mode]
await dmsControl.open({
apiKey,
apiSecret,
dmsScope
})

return { dmsControl: true }
}

/**
* @param {APIWSServer} server
* @param {Session} session
Expand Down Expand Up @@ -156,19 +117,6 @@ class ConnectionManager {
return { metricsClient: true }
}

/**
* @param {APIWSServer} server
* @param {Session} session
* @param {Object} settings
* @returns {Promise<void>}
* @private
*/
async _startDmsControl (server, session, settings) {
const { dmsScope } = session
const { dms } = settings
return this.updateDms(server, session, dms, dmsScope)
}

/**
* @param {APIWSServer} server
* @param {Session} session
Expand Down
3 changes: 1 addition & 2 deletions test/unit/lib/ws_servers/api/algos/algo_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ describe('AlgoWorker', () => {
})
// register events
assert.calledWith(AOHostStub.on.firstCall, 'error')
assert.calledWith(AOHostStub.on.secondCall, 'meta:reload')
assert.calledWith(AOHostStub.on.thirdCall, 'ao:stopped')
assert.calledWith(AOHostStub.on.secondCall, 'ao:stopped')
// connect
assert.calledWithExactly(AOHostStub.connect)
// publish opened event
Expand Down
Loading