本文整理汇总了Golang中github.com/APTrust/exchange/dpn/models.SyncResult.AddError方法的典型用法代码示例。如果您正苦于以下问题:Golang SyncResult.AddError方法的具体用法?Golang SyncResult.AddError怎么用?Golang SyncResult.AddError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/APTrust/exchange/dpn/models.SyncResult
的用法示例。
在下文中一共展示了SyncResult.AddError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: syncFixities
func (dpnSync *DPNSync) syncFixities(fixities []*models.FixityCheck, result *models.SyncResult) {
log := dpnSync.Context.MessageLog
for _, fixity := range fixities {
resp := dpnSync.LocalClient.FixityCheckCreate(fixity)
if resp.Response.StatusCode == 409 {
// Do nothing. This fixity record already exists
// on our local server.
} else if resp.Error != nil {
result.AddError(dpn.DPNTypeFixityCheck, resp.Error)
return
} else {
log.Debug("Created new fixity %s (bag %s)", fixity.FixityCheckId, fixity.Bag)
}
result.AddToSyncCount(dpn.DPNTypeFixityCheck, 1)
}
}
示例2: syncIngests
func (dpnSync *DPNSync) syncIngests(ingests []*models.Ingest, result *models.SyncResult) {
log := dpnSync.Context.MessageLog
for _, ingest := range ingests {
resp := dpnSync.LocalClient.IngestCreate(ingest)
if resp.Response.StatusCode == 409 {
// Do nothing. This ingest record already exists
// on our local server.
} else if resp.Error != nil {
result.AddError(dpn.DPNTypeIngest, resp.Error)
return
} else {
log.Debug("Created new ingest %s (bag %s)", ingest.IngestId, ingest.Bag)
}
result.AddToSyncCount(dpn.DPNTypeIngest, 1)
}
}
示例3: syncDigests
func (dpnSync *DPNSync) syncDigests(digests []*models.MessageDigest, result *models.SyncResult) {
log := dpnSync.Context.MessageLog
for _, digest := range digests {
resp := dpnSync.LocalClient.DigestGet(digest.Bag, digest.Algorithm)
if resp.Error != nil {
result.AddError(dpn.DPNTypeDigest, resp.Error)
return
}
existingDigest := resp.Digest()
if existingDigest == nil {
log.Debug("Creating new %s digest for bag %s", digest.Algorithm, digest.Bag)
resp = dpnSync.LocalClient.DigestCreate(digest)
if resp.Error != nil {
result.AddError(dpn.DPNTypeDigest, resp.Error)
return
}
}
result.AddToSyncCount(dpn.DPNTypeDigest, 1)
}
}
示例4: syncMembers
func (dpnSync *DPNSync) syncMembers(members []*models.Member, result *models.SyncResult) {
log := dpnSync.Context.MessageLog
for _, member := range members {
resp := dpnSync.LocalClient.MemberGet(member.MemberId)
if resp.Error != nil {
result.AddError(dpn.DPNTypeMember, resp.Error)
return
}
existingMember := resp.Member()
if existingMember == nil {
log.Debug("Creating new member %s (%s)", member.Name, member.MemberId)
resp = dpnSync.LocalClient.MemberCreate(member)
if resp.Error != nil {
result.AddError(dpn.DPNTypeMember, resp.Error)
return
}
}
result.AddToSyncCount(dpn.DPNTypeMember, 1)
}
}
示例5: syncRestoreRequests
func (dpnSync *DPNSync) syncRestoreRequests(xfers []*models.RestoreTransfer, result *models.SyncResult) {
log := dpnSync.Context.MessageLog
for _, xfer := range xfers {
log.Debug("Processing restore %s from %s (bag %s)", xfer.RestoreId,
xfer.FromNode, xfer.Bag)
resp := dpnSync.LocalClient.RestoreTransferGet(xfer.RestoreId)
if resp.Error != nil {
result.AddError(dpn.DPNTypeRestore, resp.Error)
return
}
existingXfer := resp.RestoreTransfer()
if existingXfer == nil {
log.Debug("Creating new restore request %s", xfer.RestoreId)
resp = dpnSync.LocalClient.RestoreTransferCreate(xfer)
if resp.Error != nil {
result.AddError(dpn.DPNTypeRestore, resp.Error)
return
}
} else if !existingXfer.UpdatedAt.Before(xfer.UpdatedAt) {
log.Debug("Skipping restore %s, because ours is same age or newer.", xfer.RestoreId)
} else {
log.Debug("Updating restore %s", xfer.RestoreId)
resp = dpnSync.LocalClient.RestoreTransferUpdate(xfer)
if resp.Error != nil {
result.AddError(dpn.DPNTypeRestore, resp.Error)
return
}
}
result.AddToSyncCount(dpn.DPNTypeRestore, 1)
}
}
示例6: syncBags
func (dpnSync *DPNSync) syncBags(bags []*models.DPNBag, result *models.SyncResult) {
log := dpnSync.Context.MessageLog
for _, bag := range bags {
log.Debug("Processing bag %s from %s", bag.UUID, bag.AdminNode)
resp := dpnSync.LocalClient.DPNBagGet(bag.UUID)
if resp.Error != nil {
log.Error(resp.Error.Error())
result.AddError(dpn.DPNTypeBag, resp.Error)
return
}
existingBag := resp.Bag()
if existingBag == nil {
log.Debug("Creating new bag %s", bag.UUID)
resp = dpnSync.LocalClient.DPNBagCreate(bag)
if resp.Error != nil {
log.Error(resp.Error.Error())
result.AddError(dpn.DPNTypeBag, resp.Error)
return
}
} else if !existingBag.UpdatedAt.Before(bag.UpdatedAt) {
log.Debug("Skipping bag %s, because ours is same age or newer.", bag.UUID)
} else {
log.Debug("Updating bag %s", bag.UUID)
resp = dpnSync.LocalClient.DPNBagUpdate(bag)
if resp.Error != nil {
log.Error(resp.Error.Error())
result.AddError(dpn.DPNTypeBag, resp.Error)
return
}
}
dpnSync.SyncIngests(bag)
result.AddToSyncCount(dpn.DPNTypeBag, 1)
}
}