Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Int 9336 dont flush after steps 2 #979

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading