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

[connectors] Launch workflows from ZendeskConnectorManager #8346

Merged
merged 17 commits into from
Oct 31, 2024

Conversation

aubin-tchoi
Copy link
Contributor

@aubin-tchoi aubin-tchoi commented Oct 30, 2024

Description

Risk

Deploy Plan

  • Deploy connectors.

@aubin-tchoi aubin-tchoi requested review from Fraggle, fontanierh, tdraier and flvndvd and removed request for Fraggle and fontanierh October 31, 2024 10:10
Comment on lines 75 to 77
const workflowStartResult = await launchZendeskSyncWorkflow({
connectorId: connector.id,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit but we usually prefer to pass proper type, here you can pass Connector.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do!

@@ -86,15 +105,52 @@ export class ZendeskConnectorManager extends BaseConnectorManager<null> {
}

async stop(): Promise<Result<undefined, Error>> {
throw new Error("Method not implemented.");
const result = await stopZendeskSyncWorkflow(this.connectorId);
return result.isErr() ? result : new Ok(undefined);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not directly returning result?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types do not match here, but this is an error in stopZendeskSyncWorkflow, will fix it and return result here, thanks for spotting

connectors/src/connectors/zendesk/index.ts Outdated Show resolved Hide resolved
"[Zendesk] Error resuming the sync workflow."
);
}
return new Ok(undefined);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems weird to not return the error in this case 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, i'll change that

}
await connector.markAsUnpaused();

const brandIds = await ZendeskBrandResource.fetchAllBrandIds({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we only resume with the brandIds?

Copy link
Contributor Author

@aubin-tchoi aubin-tchoi Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the brands are the top level collections, syncing them syncs everything

}

const dataSourceConfig = dataSourceConfigFromConnector(connector);
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the try/catch if we have a Result type? Also in many other places there is no try/catch that wraps this call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, changed that in launchZendeskSyncWorkflow a while ago and got a little bit confused here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goal here is indeed to always use the Result type by catching it if necessary in the deepest level possible and return it in launchZendeskSyncWorkflow and then in resume.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

await connector.markAsPaused();
const result = await this.stop();

return result.isErr() ? result : new Ok(undefined);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here? Can we simply return result?

});
const result = await launchZendeskSyncWorkflow({ connector, brandIds });

return result.isErr() ? result : new Ok(undefined);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here types don't match since we pass the workflow ID in the Ok of launchZendeskSyncWorkflow, turns out we don't need this workflow ID so i'll just change launchZendeskSyncWorkflow and return result everywhere appliable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flvndvd done

Copy link
Contributor

@flvndvd flvndvd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left one small comment but good to ship once fixed.

}

const dataSourceConfig = dataSourceConfigFromConnector(connector);
const result = await launchZendeskSyncWorkflow({ connector });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to wrap this in parameter in an object.
The rule is:

  • Native types that are very easy to mix up -> Wrap in an object to have specific keys
  • None-native types, use them as-is

@aubin-tchoi aubin-tchoi merged commit b1f7ebf into main Oct 31, 2024
3 checks passed
@aubin-tchoi aubin-tchoi deleted the zendesk/client branch October 31, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Zendesk] data source deletion fails at scrub with method not implemetned
2 participants