Attach retry (#202)
Merge of Attach retry branch adds inline retry for attachments. Appropriate tests included.
This commit is contained in:
parent
15e7c102a4
commit
81bdc69c5a
@ -19,7 +19,10 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const mailCategory = "mail"
|
||||
const (
|
||||
numberOfRetries = 3
|
||||
mailCategory = "mail"
|
||||
)
|
||||
|
||||
// GraphConnector is a struct used to wrap the GraphServiceClient and
|
||||
// GraphRequestAdapter from the msgraph-sdk-go. Additional fields are for
|
||||
@ -246,11 +249,16 @@ func (gc *GraphConnector) serializeMessages(user string) ([]DataCollection, erro
|
||||
return true
|
||||
}
|
||||
if *message.GetHasAttachments() {
|
||||
attached, err := gc.client.UsersById(user).MessagesById(*message.GetId()).Attachments().Get()
|
||||
if err == nil && attached != nil {
|
||||
message.SetAttachments(attached.GetValue())
|
||||
// Retry Loop
|
||||
for count := 0; count < numberOfRetries; count++ {
|
||||
attached, err := gc.client.UsersById(user).MessagesById(*message.GetId()).Attachments().Get()
|
||||
if err == nil && attached != nil {
|
||||
message.SetAttachments(attached.GetValue())
|
||||
break
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println("Retries exceeded")
|
||||
errs = WrapAndAppend(*message.GetId(), fmt.Errorf("attachment failed: %v ", err), errs)
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,8 +69,9 @@ func (suite *GraphConnectorIntegrationSuite) TestGraphConnector_ExchangeDataColl
|
||||
if err != nil {
|
||||
suite.T().Logf("Missing Data: %s\n", err.Error())
|
||||
}
|
||||
suite.NotContains(err.Error(), "attachment failed") // TODO Create Retry Exceeded Error
|
||||
exchangeData := collectionList[0]
|
||||
suite.T().Logf("Full PathData: %s\n", exchangeData.FullPath())
|
||||
suite.Greater(len(exchangeData.FullPath()), 2)
|
||||
}
|
||||
|
||||
func (suite *GraphConnectorIntegrationSuite) TestGraphConnector_restoreMessages() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user