Skip to content

Commit

Permalink
Merge pull request #979 from JupiterOne/INT-9336-dont-flush-after-ste…
Browse files Browse the repository at this point in the history
…ps-2

Int 9336 dont flush after steps 2
  • Loading branch information
Gonzalo-Avalos-Ribas authored Oct 10, 2023
2 parents 0267c15 + 4cb0e15 commit 52e7821
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/integration-sdk-core/src/types/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ export interface GraphObjectStore {
getIndexMetadataForGraphObjectType?: (
params: GetIndexMetadataForGraphObjectTypeParams,
) => GraphObjectIndexMetadata | undefined;

getStepsStored?: () => string[];
}
14 changes: 11 additions & 3 deletions packages/integration-sdk-runtime/src/execution/dependencyGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ export function executeStepDependencyGraph<
Array.from(stepResultsMap.keys()).pop() as string,
);
}
const stepsInvolvedInUpload = graphObjectStore.getStepsStored
? graphObjectStore.getStepsStored()
: [];
await graphObjectStore.flush(
async (entities) =>
entities.length
Expand All @@ -470,13 +473,18 @@ export function executeStepDependencyGraph<
);
try {
await uploader?.waitUntilUploadsComplete();
} catch (error) {
} catch (err) {
executionContext.logger.publishErrorEvent({
name: IntegrationErrorEventName.UnexpectedError,
description: 'Upload to persister failed',
});
//How can we fail gracefully here?
throw error;
for (const stepId of stepsInvolvedInUpload) {
executionContext.logger.stepFailure(
workingGraph.getNodeData(stepId),
err,
);
stepResultsMap[stepId] = StepResultStatus.FAILURE;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ export class FileSystemGraphObjectStore implements GraphObjectStore {
integrationStepsToGraphObjectIndexMetadataMap(params.integrationSteps);
}
}
getStepsStored() {
return this.localGraphObjectStore.getStepsStored();
}

async addEntities(
stepId: string,
Expand Down
18 changes: 18 additions & 0 deletions packages/integration-sdk-runtime/src/storage/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,22 @@ export class InMemoryGraphObjectStore implements GraphObjectStore {
0,
);
}

getStepsStored(): string[] {
const stepIds: string[] = [];

for (const [_, graphObjectData] of this.relationshipKeyToRelationshipMap) {
const { stepId } = graphObjectData;
if (!stepIds.includes(stepId)) {
stepIds.push(stepId);
}
}
for (const [_, graphObjectData] of this.entityKeyToEntityMap) {
const { stepId } = graphObjectData;
if (!stepIds.includes(stepId)) {
stepIds.push(stepId);
}
}
return stepIds;
}
}

0 comments on commit 52e7821

Please sign in to comment.