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