Merge pull request #36 from AAMasters/develop

Beta 4
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2020-05-03 15:49:55 +02:00
commit 0c332dd214
7 files changed
+86 -20

No files matched your search

+3 -3
View File
@@ -45,14 +45,14 @@ function newDailyFiles () {
}
}
function initialize (pDataMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pDatetime, pTimeFrame, callBackFunction) {
function initialize (pDataMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pDatetime, pTimeFrame, pHost, pPort, pEventsServerClient, callBackFunction) {
try {
callBackWhenFileReceived = callBackFunction
let exchange = pExchange
fileCloud = newFileCloud()
fileCloud.initialize(pBot)
fileCloud.initialize(pBot, pHost, pPort)
/* Some Validations */
if (pDataset.code.validTimeFrames === undefined) {
@@ -114,7 +114,7 @@ function newDailyFiles () {
if (pDataset.code.validTimeFrames.includes(periodName) === true) {
let fileCursor = newFileCursor()
fileCursor.eventHandler = thisObject.eventHandler // We share our event handler with each file cursor, so that they can raise events there when files are changed.s
fileCursor.initialize(fileCloud, pDataMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, periodName, periodTime, pDatetime, pTimeFrame, beginDateRange, endDateRange, onInitialized)
fileCursor.initialize(fileCloud, pDataMine, pBot, pSession, pProduct, pDataset, exchange, pMarket, periodName, periodTime, pDatetime, pTimeFrame, beginDateRange, endDateRange, pEventsServerClient, onInitialized)
function onInitialized (err) {
try {
switch (err.result) {
+4 -4
View File
@@ -17,12 +17,12 @@ function newFileCloud () {
initialize: initialize
}
let blobService
let fileStorage
return thisObject
function initialize (pBot) {
blobService = newFileStorage()
function initialize (pBot, pHost, pPort) {
fileStorage = newFileStorage(pHost, pPort)
}
function getFile (pDataMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction) {
@@ -121,7 +121,7 @@ function newFileCloud () {
if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> filePath = ' + filePath) }
if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> fileName = ' + fileName) }
blobService.getBlobToText(filePath + '/' + fileName, undefined, onFileReceived)
fileStorage.getFileFromHost(filePath + '/' + fileName, onFileReceived)
function onFileReceived (err, text, response) {
try {
+20 -1
View File
@@ -34,6 +34,7 @@ function newFileCursor () {
let timeFrame
let beginDateRange
let endDateRange
let eventsServerClient
let finalized = false
@@ -61,6 +62,7 @@ function newFileCursor () {
timeFrame = undefined
beginDateRange = undefined
endDateRange = undefined
eventsServerClient = undefined
thisObject.files = undefined
cursorDate = undefined
@@ -73,7 +75,23 @@ function newFileCursor () {
}
}
function initialize (pFileCloud, pDataMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, pPeriodName, pTimeFrame, pCursorDate, pCurrentTimeFrame, pBeginDateRange, pEndDateRange, callBackFunction) {
function initialize (
pFileCloud,
pDataMine,
pBot,
pSession,
pProduct,
pDataset,
pExchange,
pMarket,
pPeriodName,
pTimeFrame,
pCursorDate,
pCurrentTimeFrame,
pBeginDateRange,
pEndDateRange,
pEventsServerClient,
callBackFunction) {
try {
market = pMarket
exchange = pExchange
@@ -88,6 +106,7 @@ function newFileCursor () {
timeFrame = pTimeFrame
beginDateRange = pBeginDateRange
endDateRange = pEndDateRange
eventsServerClient = pEventsServerClient
let key = dataMine.code.codeName + '-' + bot.code.codeName + '-' + product.code.codeName + '-' + dataset.code.codeName + '-' + exchange.name + '-' + market.baseAsset + '/' + market.quotedAsset
let callerId = key + '-' + periodName + newUniqueId()
+16 -2
View File
@@ -32,6 +32,7 @@ function newFileSequence () {
let eventSubscriptionIdDatasetUpdated
let callerId
let eventsServerClient
return thisObject
@@ -52,6 +53,7 @@ function newFileSequence () {
session = undefined
dataset = undefined
product = undefined
eventsServerClient = undefined
finalized = true
} catch (err) {
@@ -59,7 +61,18 @@ function newFileSequence () {
}
}
function initialize (pDataMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, callBackFunction) {
function initialize (
pDataMine,
pBot,
pSession,
pProduct,
pDataset,
pExchange,
pMarket,
pHost,
pPort,
pEventsServerClient,
callBackFunction) {
try {
exchange = pExchange
market = pMarket
@@ -68,9 +81,10 @@ function newFileSequence () {
session = pSession
dataset = pDataset
product = pProduct
eventsServerClient = pEventsServerClient
fileCloud = newFileCloud()
fileCloud.initialize(bot)
fileCloud.initialize(bot, pHost, pPort)
callerId = newUniqueId()
+14 -6
View File
@@ -1,4 +1,4 @@
function newFileStorage () {
function newFileStorage (host, port) {
const MODULE_NAME = 'File Storage'
const INFO_LOG = false
const logger = newWebDebugLog()
@@ -24,20 +24,28 @@ function newFileStorage () {
]
let thisObject = {
getBlobToText: getBlobToText
getFileFromHost: getFileFromHost
}
if (host === '' || host === undefined) { host = 'localhost' }
if (port === '' || port === undefined) { port = '34247' }
return thisObject
async function getBlobToText (filePath, host, callBackFunction, pathComplete) {
async function getFileFromHost (filePath, callBackFunction, pathComplete) {
try {
if (INFO_LOG === true) { logger.write('[INFO] getBlobToText -> Entering function.') }
if (INFO_LOG === true) { logger.write('[INFO] getFileFromHost -> Entering function.') }
let folder = ''
if (pathComplete === false || pathComplete === undefined) {
folder = 'Storage/'
}
callServer(undefined, folder + filePath, (response, fileContent) => {
let url = folder + filePath
if (host !== undefined) {
url = 'http://' + host + ':' + port + '/' + folder + filePath
}
callServer(undefined, url, (response, fileContent) => {
if (response.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, fileContent)
} else {
@@ -48,7 +56,7 @@ function newFileStorage () {
if (verifyRetry(err.code) && currentRetry < MAX_RETRY) {
currentRetry++
if (INFO_LOG === true) { console.log('[INFO] getTextFile -> Retrying connection to the server because received error: ' + err.code + '. Retry #: ' + currentRetry) }
getBlobToText(filePath, host, callBackFunction)
getFileFromHost(filePath, callBackFunction)
} else if (err.message === 'Request aborted') {
let err = { code: 'The specified key does not exist.' }
callBackFunction(err)
+16 -2
View File
@@ -37,6 +37,7 @@ function newMarketFiles () {
let finalized = false
let eventSubscriptionIdDatasetUpdated = []
let eventsServerClient
return thisObject
@@ -60,6 +61,7 @@ function newMarketFiles () {
dataset = undefined
product = undefined
periodName = undefined
eventsServerClient = undefined
finalized = true
} catch (err) {
@@ -67,7 +69,18 @@ function newMarketFiles () {
}
}
function initialize (pDataMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, callBackFunction) {
function initialize (
pDataMine,
pBot,
pSession,
pProduct,
pDataset,
pExchange,
pMarket,
pHost,
pPort,
pEventsServerClient,
callBackFunction) {
try {
exchange = pExchange
market = pMarket
@@ -76,9 +89,10 @@ function newMarketFiles () {
session = pSession
dataset = pDataset
product = pProduct
eventsServerClient = pEventsServerClient
fileCloud = newFileCloud()
fileCloud.initialize(pBot)
fileCloud.initialize(pBot, pHost, pPort)
/* Some Validations */
if (dataset.code.validTimeFrames === undefined) {
+13 -2
View File
@@ -16,7 +16,18 @@ function newSingleFile () {
return thisObject
function initialize (pDataMine, pBot, pSession, pProduct, pDataset, pExchange, pMarket, callBackFunction) {
function initialize (
pDataMine,
pBot,
pSession,
pProduct,
pDataset,
pExchange,
pMarket,
pHost,
pPort,
pEventsServerClient,
callBackFunction) {
try {
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
if (INFO_LOG === true) { logger.write('[INFO] initialize -> key = ' + pDataMine.code.codeName + '-' + pBot.code.codeName + '-' + pProduct.code.codeName) }
@@ -24,7 +35,7 @@ function newSingleFile () {
let exchange = pExchange
fileCloud = newFileCloud()
fileCloud.initialize(pBot)
fileCloud.initialize(pBot, pHost, pPort)
/* Now we will get the file */