Skip to content

Commit

Permalink
fix: subscribe to org
Browse files Browse the repository at this point in the history
  • Loading branch information
wwills2 committed Jan 6, 2025
1 parent afcc62e commit 4c16a89
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions src/models/organizations/organizations.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,8 @@ class Organization extends Model {
logger.debug(
`determining datamodel version singleton id for org ${orgUid}`,
);
let dataModelVersionStoreId = null;
while (!dataModelVersionStoreId) {
let orgStoreData = null;
let orgStoreData = null;
while (!orgStoreData) {
try {
orgStoreData = await datalayer.getSubscribedStoreData(orgUid);
} catch (error) {
Expand All @@ -607,23 +606,22 @@ class Organization extends Model {
logger.debug(`${error.message}. RETRYING`);
await new Promise((resolve) => setTimeout(resolve, 10000));
}
}

// here registryId is actually the data model version store that points to the registry store
dataModelVersionStoreId = orgStoreData?.registryId;
if (!dataModelVersionStoreId) {
throw new Error(
`failed to get registry datamodel version singleton id from orgUid store ${orgUid}. rpc function returned: ${orgStoreData}`,
);
}
logger.debug(
`the registry datamodel version pointer singleton id for organization ${orgUid} is ${dataModelVersionStoreId}`,
// here registryId is actually the data model version store that points to the registry store
const dataModelVersionStoreId = orgStoreData.registryId;
if (!dataModelVersionStoreId) {
throw new Error(
`failed to get registry datamodel version singleton id from orgUid store ${orgUid}. rpc function returned: ${orgStoreData}`,
);
}
logger.debug(
`the registry datamodel version pointer singleton id for organization ${orgUid} is ${dataModelVersionStoreId}`,
);

logger.debug(`determining registry store singleton id for org ${orgUid}`);
let registryStoreId = null;
while (!registryStoreId) {
let dataModelVersionStoreData = null;
let dataModelVersionStoreData = null;
while (!dataModelVersionStoreData) {
try {
dataModelVersionStoreData = await datalayer.getSubscribedStoreData(
dataModelVersionStoreId,
Expand All @@ -635,18 +633,18 @@ class Organization extends Model {
logger.debug(`${error.message}. RETRYING`);
await new Promise((resolve) => setTimeout(resolve, 10000));
}
}

// here v1 is actually the registry store id
registryStoreId = dataModelVersionStoreData?.v1;
if (!registryStoreId) {
throw new Error(
`failed to get registry singleton id from datamodel version singleton store ${dataModelVersionStoreId}. rpc function returned: ${dataModelVersionStoreData}`,
);
}
logger.debug(
`the registry singleton id for organization ${orgUid} is ${dataModelVersionStoreId}`,
// here v1 is actually the registry store id
const registryStoreId = dataModelVersionStoreData?.v1;
if (!registryStoreId) {
throw new Error(
`failed to get registry singleton id from datamodel version singleton store ${dataModelVersionStoreId}. rpc function returned: ${dataModelVersionStoreData}`,
);
}
logger.debug(
`the registry singleton id for organization ${orgUid} is ${registryStoreId}`,
);

logger.debug(`checking registry store singleton for org ${orgUid}`);
const subscribedToRegistryStore =
Expand Down

0 comments on commit 4c16a89

Please sign in to comment.