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

feat: onboard initial marketo builk upload implementation #5114

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

utsabc
Copy link
Member

@utsabc utsabc commented Sep 18, 2024

Description

This PR implements the Marketo Bulk upload Integration using the following API

We use the Async upload destination framework to onboard the destination

Linear Ticket

Linear Ticket

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 22.61380% with 527 lines in your changes missing coverage. Please review.

Project coverage is 72.97%. Comparing base (da9f8c8) to head (5fabdfd).

Files with missing lines Patch % Lines
...onmanager/marketo-bulk-upload/marketobulkupload.go 0.00% 226 Missing ⚠️
...stinationmanager/marketo-bulk-upload/apiService.go 0.00% 146 Missing ⚠️
...yncdestinationmanager/marketo-bulk-upload/utils.go 59.31% 79 Missing and 4 partials ⚠️
...cdestinationmanager/marketo-bulk-upload/manager.go 0.00% 38 Missing ⚠️
...inationmanager/marketo-bulk-upload/configParser.go 0.00% 18 Missing ⚠️
...tinationmanager/marketo-bulk-upload/authService.go 61.53% 11 Missing and 4 partials ⚠️
...ter/batchrouter/asyncdestinationmanager/manager.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5114      +/-   ##
==========================================
- Coverage   73.19%   72.97%   -0.22%     
==========================================
  Files         417      423       +6     
  Lines       59085    59475     +390     
==========================================
+ Hits        43246    43402     +156     
- Misses      13426    13650     +224     
- Partials     2413     2423      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

func sendHTTPRequest(uploadURL, csvFilePath string, accessToken string, deduplicationField string) (*http.Response, error) {
file, err := os.Open(csvFilePath)
if err != nil {
return nil, err
Copy link
Member

Choose a reason for hiding this comment

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

Apart from returning error only, we can add oneliner as follows:
fmt.Errorf("error while opening the file: %v", err)

Copy link
Member Author

Choose a reason for hiding this comment

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

This fixed

return m.attemptImport(uploadURL, csvFilePath, deduplicationField, uploadTimeStat)
}

return "", apiError
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a stat here to monitor how many times the retryable error occurred so that we can take steps if any unnecessary retries happen?

Copy link
Member Author

Choose a reason for hiding this comment

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

But wont we have this in jobs db - and I believe router should have such metrics based on jobs db

errorMessage := ""
if !marketoResponse.Success {
if len(marketoResponse.Errors) > 0 {
errorCode := marketoResponse.Errors[0].Code
Copy link
Member

Choose a reason for hiding this comment

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

Don't we need to consider other errors from errors array?

Copy link
Member Author

Choose a reason for hiding this comment

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

We only get 1 error object form error array so far thats what we have seen


// If the access token is nil or about to expire in 10 seconds, wait 10 seconds and fetch a new access token
} else if m.accessToken.FetchedAt+m.accessToken.ExpiresIn < 10 {
time.Sleep(11 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to wait? Can't we generate a new accessToken when there is a valid accessToken?

Copy link
Contributor

Choose a reason for hiding this comment

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

sudip, no if we call it within the valid window, same accessToken will be returned and that will eventually fail.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have removed this logic for now made it very simple, for now since marketo returns same code and since we wll call only after an hour I think if we really see need then we can optimse

}

return nil
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this separate file? Can't we move this function to util?

Copy link
Member Author

Choose a reason for hiding this comment

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

This we will deprecate once we move to vdm hence for now kept separate (this is only needed to parse the ui mapping)

StatusCode: 500,
HasFailed: true,
Error: asyncResponse.Error,
fmt.Println("File Upload Started for Dest Type ", destType)
Copy link
Contributor

@shrouti1507 shrouti1507 Oct 23, 2024

Choose a reason for hiding this comment

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

is it intentional ? or planning to remove

Copy link
Member Author

Choose a reason for hiding this comment

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

Using for debugging will remove

Copy link
Contributor

@shrouti1507 shrouti1507 left a comment

Choose a reason for hiding this comment

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

Are we planning to add the flow level test cases later on?

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.

3 participants