Skip to content

Commit

Permalink
feat: Provision separate DB per user in runner
Browse files Browse the repository at this point in the history
  • Loading branch information
morgsmccauley committed Jul 18, 2023
1 parent 992cc20 commit 146fa74
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions indexer-js-queue-handler/indexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ export default class Indexer {
const functionNameWithoutAccount = function_name.split('/')[1].replace(/[.-]/g, '_');

if (options.provision && !indexerFunction["provisioned"]) {
const schemaName = `${function_name.replace(/[.\/-]/g, '_')}`
const userName = function_name.split('/')[0].replace(/[.-]/g, '_');
const databaseName = userName;

try {
if (!await this.deps.provisioner.doesEndpointExist(schemaName)) {
if (!await this.deps.provisioner.isUserApiProvisioned(databaseName)) {
await this.setStatus(function_name, block_height, 'PROVISIONING');
simultaneousPromises.push(this.writeLog(function_name, block_height, 'Provisioning endpoint: starting'));

await this.deps.provisioner.createAuthenticatedEndpoint(schemaName, hasuraRoleName, indexerFunction.schema);
await this.deps.provisioner.provisionUserApi(userName, indexerFunction.schema);

simultaneousPromises.push(this.writeLog(function_name, block_height, 'Provisioning endpoint: successful'));
}
Expand Down

0 comments on commit 146fa74

Please sign in to comment.