當前位置: 首頁>>代碼示例>>Golang>>正文


Golang PendingStopMessage.LogDescription方法代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/hm9000/models.PendingStopMessage.LogDescription方法的典型用法代碼示例。如果您正苦於以下問題:Golang PendingStopMessage.LogDescription方法的具體用法?Golang PendingStopMessage.LogDescription怎麽用?Golang PendingStopMessage.LogDescription使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cloudfoundry/hm9000/models.PendingStopMessage的用法示例。


在下文中一共展示了PendingStopMessage.LogDescription方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例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


注:本文中的github.com/cloudfoundry/hm9000/models.PendingStopMessage.LogDescription方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。