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

Golang models.PendingStopMessage类代码示例

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

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



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

示例1: stopMessageToSend

func (sender *Sender) stopMessageToSend(message models.PendingStopMessage) (models.StopMessage, bool) {
	appKey := sender.store.AppKey(message.AppGuid, message.AppVersion)
	app, found := sender.apps[appKey]

	if !found {
		sender.logger.Info("Skipping sending stop message: instance is no longer running", message.LogDescription())
		return models.StopMessage{}, false
	}

	instanceToStop := app.InstanceWithGuid(message.InstanceGuid)
	messageToSend := models.StopMessage{
		AppGuid:       message.AppGuid,
		AppVersion:    message.AppVersion,
		InstanceGuid:  message.InstanceGuid,
		InstanceIndex: instanceToStop.InstanceIndex,
		MessageId:     message.MessageId,
	}

	if !app.IsDesired() {
		sender.logger.Info("Sending stop message: instance is running, app is no longer desired", message.LogDescription(), app.LogDescription())
		messageToSend.IsDuplicate = false
		return messageToSend, true
	}

	if !app.IsIndexDesired(instanceToStop.InstanceIndex) {
		sender.logger.Info("Sending stop message: index of instance to stop is beyond desired # of instances", message.LogDescription(), app.LogDescription())
		messageToSend.IsDuplicate = false
		return messageToSend, true
	}

	if instanceToStop.State == models.InstanceStateEvacuating {
		sender.logger.Info("Sending stop message for evacuating app", message.LogDescription(), app.LogDescription())
		messageToSend.IsDuplicate = true
		return messageToSend, true
	}

	if len(app.StartingOrRunningInstancesAtIndex(instanceToStop.InstanceIndex)) > 1 {
		sender.logger.Info("Sending stop message: instance is a duplicate running at a desired index", message.LogDescription(), app.LogDescription())
		messageToSend.IsDuplicate = true
		return messageToSend, true
	}

	sender.logger.Info("Skipping sending stop message: instance is running on a desired index (and there are no other instances running at that index)", message.LogDescription(), app.LogDescription())
	return models.StopMessage{}, false
}
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:45,代码来源:sender.go


示例2: sendStopMessage

func (sender *Sender) sendStopMessage(stopMessage models.PendingStopMessage) {
	messageToSend, shouldSend := sender.stopMessageToSend(stopMessage)
	if shouldSend {
		err := sender.messageBus.Publish(sender.conf.SenderNatsStopSubject, messageToSend.ToJSON())

		if err != nil {
			sender.logger.Error("Failed to send stop message", err, stopMessage.LogDescription())
			sender.didSucceed = false
			return
		}

		sender.sentStopMessages = append(sender.sentStopMessages, stopMessage)

		if stopMessage.KeepAlive == 0 {
			sender.queueStopMessageForDeletion(stopMessage, "sent stop message with no keep alive")
		} else {
			sender.markStopMessageSent(stopMessage)
		}
	} else {
		sender.queueStopMessageForDeletion(stopMessage, "stop message that will not be sent")
	}
}
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:22,代码来源:sender.go


示例3: appendStopMessageIfNotDuplicate

func (a *appAnalyzer) appendStopMessageIfNotDuplicate(message models.PendingStopMessage, loggingMessage string, additionalDetails map[string]string) {
	existingMessage, alreadyQueued := a.existingPendingStopMessages[message.StoreKey()]
	if !alreadyQueued {
		a.logger.Info(fmt.Sprintf("Enqueuing Stop Message: %s", loggingMessage), message.LogDescription(), additionalDetails)
		a.stopMessages[message.StoreKey()] = message
	} else {
		a.logger.Info(fmt.Sprintf("Skipping Already Enqueued Stop Message: %s", loggingMessage), existingMessage.LogDescription(), additionalDetails)
	}
}
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:9,代码来源:app_analyzer.go


示例4: queueStopMessageForDeletion

func (sender *Sender) queueStopMessageForDeletion(stopMessage models.PendingStopMessage, reason string) {
	sender.logger.Info(fmt.Sprintf("Deleting %s", reason), stopMessage.LogDescription())
	sender.stopMessagesToDelete = append(sender.stopMessagesToDelete, stopMessage)
}
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:4,代码来源:sender.go


示例5: markStopMessageSent

func (sender *Sender) markStopMessageSent(stopMessage models.PendingStopMessage) {
	stopMessage.SentOn = sender.timeProvider.Time().Unix()
	sender.stopMessagesToSave = append(sender.stopMessagesToSave, stopMessage)
}
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:4,代码来源:sender.go


示例6:

	"github.com/cloudfoundry/hm9000/models"
	. "github.com/cloudfoundry/hm9000/store"
	"github.com/cloudfoundry/hm9000/testhelpers/fakelogger"
	"github.com/cloudfoundry/storeadapter"
	"github.com/cloudfoundry/storeadapter/etcdstoreadapter"
	"github.com/cloudfoundry/storeadapter/workerpool"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"time"
)

var _ = Describe("Storing PendingStopMessages", func() {
	var (
		store        Store
		storeAdapter storeadapter.StoreAdapter
		conf         *config.Config
		message1     models.PendingStopMessage
		message2     models.PendingStopMessage
		message3     models.PendingStopMessage
	)

	BeforeEach(func() {
		var err error
		conf, err = config.DefaultConfig()
		Ω(err).ShouldNot(HaveOccurred())
		storeAdapter = etcdstoreadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), workerpool.NewWorkerPool(conf.StoreMaxConcurrentRequests))
		err = storeAdapter.Connect()
		Ω(err).ShouldNot(HaveOccurred())

		message1 = models.NewPendingStopMessage(time.Unix(100, 0), 10, 4, "ABC", "123", "XYZ", models.PendingStopMessageReasonInvalid)
		message2 = models.NewPendingStopMessage(time.Unix(100, 0), 10, 4, "DEF", "456", "ALPHA", models.PendingStopMessageReasonInvalid)
		message3 = models.NewPendingStopMessage(time.Unix(100, 0), 10, 4, "GHI", "789", "BETA", models.PendingStopMessageReasonInvalid)
开发者ID:karlpilkington,项目名称:golang-devops-stuff,代码行数:32,代码来源:pending_stop_messages_test.go


示例7: markStopMessageSent

func (sender *Sender) markStopMessageSent(stopMessage models.PendingStopMessage) {
	stopMessage.SentOn = sender.currentTime.Unix()
	sender.stopMessagesToSave = append(sender.stopMessagesToSave, stopMessage)
}
开发者ID:nagyistge,项目名称:hm9000,代码行数:4,代码来源:sender.go


示例8:

				})

				It("should neither delete the message nor send it", func() {
					messages, _ := store.GetPendingStartMessages()
					Ω(messages).Should(HaveLen(1))
					Ω(messageBus.PublishedMessages).ShouldNot(HaveKey("hm9000.start"))
				})
			})
		})
	})

	Context("when there are stop messages", func() {
		var keepAliveTime int
		var sentOn int64
		var err error
		var pendingMessage models.PendingStopMessage
		var storeSetErrInjector *fakestoreadapter.FakeStoreAdapterErrorInjector

		JustBeforeEach(func() {
			store.SyncHeartbeats(app.Heartbeat(2))

			pendingMessage = models.NewPendingStopMessage(time.Unix(100, 0), 30, keepAliveTime, app.AppGuid, app.AppVersion, app.InstanceAtIndex(0).InstanceGuid, models.PendingStopMessageReasonInvalid)
			pendingMessage.SentOn = sentOn
			store.SavePendingStopMessages(
				pendingMessage,
			)

			storeAdapter.SetErrInjector = storeSetErrInjector
			err = sender.Send()
		})
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:30,代码来源:sender_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang store.NewStore函数代码示例发布时间:2022-05-23
下一篇:
Golang models.PendingStartMessage类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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