-
Notifications
You must be signed in to change notification settings - Fork 108
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
Conversation
537061e
to
893373b
Compare
const workflowStartResult = await launchZendeskSyncWorkflow({ | ||
connectorId: connector.id, | ||
}); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
"[Zendesk] Error resuming the sync workflow." | ||
); | ||
} | ||
return new Ok(undefined); |
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
Co-authored-by: Flavien David <[email protected]>
} | ||
|
||
const dataSourceConfig = dataSourceConfigFromConnector(connector); | ||
try { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flvndvd done
There was a problem hiding this 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 }); |
There was a problem hiding this comment.
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
Description
ZendeskConfigurations
(fetchById
mistook forfetchByConnectorId
).Risk
Deploy Plan