本文整理匯總了Golang中bosh/mbus/fakes.FakeHandler.SendToHealthManagerCallBack方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeHandler.SendToHealthManagerCallBack方法的具體用法?Golang FakeHandler.SendToHealthManagerCallBack怎麽用?Golang FakeHandler.SendToHealthManagerCallBack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bosh/mbus/fakes.FakeHandler
的用法示例。
在下文中一共展示了FakeHandler.SendToHealthManagerCallBack方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
//.........這裏部分代碼省略.........
platform.FakeVitalsService.GetVitals = boshvitals.Vitals{
Load: []string{"a", "b", "c"},
}
})
expectedJobName := "fake-job"
expectedJobIndex := 1
expectedHb := boshmbus.Heartbeat{
Job: &expectedJobName,
Index: &expectedJobIndex,
JobState: "fake-state",
Vitals: boshvitals.Vitals{Load: []string{"a", "b", "c"}},
}
It("sends initial heartbeat", func() {
// Configure periodic heartbeat every 5 hours
// so that we are sure that we will not receive it
agent = New(logger, handler, platform, actionDispatcher, alertSender, jobSupervisor, specService, 5*time.Hour)
// Immediately exit after sending initial heartbeat
handler.SendToHealthManagerErr = errors.New("stop")
err := agent.Run()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("stop"))
Expect(handler.HMRequests()).To(Equal([]fakembus.HMRequest{
fakembus.HMRequest{Topic: "heartbeat", Payload: expectedHb},
}))
})
It("sends periodic heartbeats", func() {
sentRequests := 0
handler.SendToHealthManagerCallBack = func(_ fakembus.HMRequest) {
sentRequests++
if sentRequests == 3 {
handler.SendToHealthManagerErr = errors.New("stop")
}
}
err := agent.Run()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("stop"))
Expect(handler.HMRequests()).To(Equal([]fakembus.HMRequest{
fakembus.HMRequest{Topic: "heartbeat", Payload: expectedHb},
fakembus.HMRequest{Topic: "heartbeat", Payload: expectedHb},
fakembus.HMRequest{Topic: "heartbeat", Payload: expectedHb},
}))
})
})
Context("when the agent fails to get job spec for a heartbeat", func() {
BeforeEach(func() {
specService.GetErr = errors.New("fake-spec-service-error")
handler.KeepOnRunning()
})
It("returns the error", func() {
err := agent.Run()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-spec-service-error"))
})
})
Context("when the agent fails to get vitals for a heartbeat", func() {