Skip to content

Commit

Permalink
feat(connect): bump scheduler-utils and expose GRAPHQL_MAX_RETRIES an…
Browse files Browse the repository at this point in the history
…d GRAPHQL_RETRY_BACKOFF
  • Loading branch information
TillaTheHun0 committed Aug 6, 2024
1 parent d2a8bf4 commit 758bc20
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 23 deletions.
31 changes: 15 additions & 16 deletions connect/package-lock.json

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

4 changes: 2 additions & 2 deletions connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
"test:integration": "cd ./test/e2e && npm test"
},
"dependencies": {
"@permaweb/ao-scheduler-utils": "~0.0.20",
"@permaweb/ao-scheduler-utils": "~0.0.23",
"buffer": "^6.0.3",
"debug": "^4.3.5",
"debug": "^4.3.6",
"hyper-async": "^1.1.2",
"mnemonist": "^0.39.8",
"ramda": "^0.30.1",
Expand Down
4 changes: 3 additions & 1 deletion connect/src/index.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const GATEWAY_URL = globalThis.GATEWAY_URL || undefined
const MU_URL = globalThis.MU_URL || undefined
const CU_URL = globalThis.CU_URL || undefined
const GRAPHQL_URL = globalThis.GRAPHQL_URL || undefined
const GRAPHQL_MAX_RETRIES = globalThis.GRAPHQL_MAX_RETRIES || undefined
const GRAPHQL_RETRY_BACKOFF = globalThis.GRAPHQL_RETRY_BACKOFF || undefined

const { result, results, message, spawn, monitor, unmonitor, dryrun, assign } = connect({ GATEWAY_URL, MU_URL, CU_URL, GRAPHQL_URL })
const { result, results, message, spawn, monitor, unmonitor, dryrun, assign } = connect({ GATEWAY_URL, MU_URL, CU_URL, GRAPHQL_URL, GRAPHQL_MAX_RETRIES, GRAPHQL_RETRY_BACKOFF })

export { result, results, message, spawn, monitor, unmonitor, dryrun, assign }
export { connect }
Expand Down
12 changes: 9 additions & 3 deletions connect/src/index.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ export { serializeCron } from './lib/serializeCron/index.js'
*
* - a GATEWAY_URL
* - a GRAPHQL_URL (defaults to GATEWAY_URL/graphql)
* - a GRAPHQL_MAX_RETRIES. Defaults to 0
* - a GRAPHQL_RETRY_BACKOFF. Defaults to 300 (moot if GRAPHQL_MAX_RETRIES is set to 0)
* - a Messenger Unit URL
* - a Compute Unit URL
*
* If any url is not provided, an SDK default will be used.
* If any value is not provided, an SDK default will be used.
* Invoking connect() with no parameters or an empty object is functionally equivalent
* to using the top-lvl exports of the SDK ie.
*
Expand All @@ -45,18 +47,22 @@ export { serializeCron } from './lib/serializeCron/index.js'
* } from '@permaweb/ao-sdk';
*
* // These are functionally equivalent
* connect() == { spawn, message, result, monitor }
* connect() == { spawn, message, result, results, monitor }
*
* @typedef Services
* @property {string} [GATEWAY_URL] - the url of the desried Gateway.
* @property {string} [GRAPHQL_URL] - the url of the desired Arweave Gateway GraphQL Server
* @property {number} [GRAPHQL_MAX_RETRIES] - the number of times to retry querying the gateway, utilizing an exponential backoff
* @property {number} [GRAPHQL_RETRY_BACKOFF] - the initial backoff, in milliseconds (moot if GRAPHQL_MAX_RETRIES is set to 0)
* @property {string} [MU_URL] - the url of the desried ao Messenger Unit.
* @property {string} [CU_URL] - the url of the desried ao Compute Unit.
*
* @param {Services} [services]
*/
export function connect ({
GRAPHQL_URL,
GRAPHQL_MAX_RETRIES,
GRAPHQL_RETRY_BACKOFF,
GATEWAY_URL = DEFAULT_GATEWAY_URL,
MU_URL = DEFAULT_MU_URL,
CU_URL = DEFAULT_CU_URL
Expand All @@ -65,7 +71,7 @@ export function connect ({

if (!GRAPHQL_URL) GRAPHQL_URL = joinUrl({ url: GATEWAY_URL, path: '/graphql' })

const { validate } = schedulerUtilsConnect({ cacheSize: 100, GRAPHQL_URL })
const { validate } = schedulerUtilsConnect({ cacheSize: 100, GRAPHQL_URL, GRAPHQL_MAX_RETRIES, GRAPHQL_RETRY_BACKOFF })

const processMetaCache = SuClient.createProcessMetaCache({ MAX_SIZE: 25 })

Expand Down
4 changes: 3 additions & 1 deletion connect/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ const GATEWAY_URL = process.env.GATEWAY_URL || undefined
const MU_URL = process.env.MU_URL || undefined
const CU_URL = process.env.CU_URL || undefined
const GRAPHQL_URL = process.env.GRAPHQL_URL || undefined
const GRAPHQL_MAX_RETRIES = process.env.GRAPHQL_MAX_RETRIES || undefined
const GRAPHQL_RETRY_BACKOFF = process.env.GRAPHQL_RETRY_BACKOFF || undefined

const { result, results, message, spawn, monitor, unmonitor, dryrun, assign } = connect({ GATEWAY_URL, MU_URL, CU_URL, GRAPHQL_URL })
const { result, results, message, spawn, monitor, unmonitor, dryrun, assign } = connect({ GATEWAY_URL, MU_URL, CU_URL, GRAPHQL_URL, GRAPHQL_MAX_RETRIES, GRAPHQL_RETRY_BACKOFF })

export { result, results, message, spawn, monitor, unmonitor, dryrun, assign }
export { connect }
Expand Down

0 comments on commit 758bc20

Please sign in to comment.