• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang models.SyncResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/APTrust/exchange/dpn/models.SyncResult的典型用法代码示例。如果您正苦于以下问题:Golang SyncResult类的具体用法?Golang SyncResult怎么用?Golang SyncResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SyncResult类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: 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)
	}
}
开发者ID:APTrust,项目名称:exchange,代码行数:31,代码来源:dpn_sync.go


示例2: 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)
	}
}
开发者ID:APTrust,项目名称:exchange,代码行数:34,代码来源:dpn_sync.go


示例3: 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)
	}
}
开发者ID:APTrust,项目名称:exchange,代码行数:16,代码来源:dpn_sync.go


示例4: 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)
	}
}
开发者ID:APTrust,项目名称:exchange,代码行数:16,代码来源:dpn_sync.go


示例5: 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)
	}
}
开发者ID:APTrust,项目名称:exchange,代码行数:20,代码来源:dpn_sync.go


示例6: 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)
	}
}
开发者ID:APTrust,项目名称:exchange,代码行数:20,代码来源:dpn_sync.go



注:本文中的github.com/APTrust/exchange/dpn/models.SyncResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang network.DPNRestClient类代码示例发布时间:2022-05-24
下一篇:
Golang models.Deployment类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap