本文整理汇总了Golang中github.com/cloudfoundry-incubator/pat/context.Context.PutInt方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.PutInt方法的具体用法?Golang Context.PutInt怎么用?Golang Context.PutInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry-incubator/pat/context.Context
的用法示例。
在下文中一共展示了Context.PutInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
Ω(exists).Should(Equal(true))
result, exists = localContext.GetString("key2")
Ω(result).Should(Equal("123"))
Ω(exists).Should(Equal(true))
})
It("can store string value as provided", func() {
localContext.PutString("str", "This is a long string \n")
result, _ := localContext.GetString("str")
Ω(result).Should(Equal("This is a long string \n"))
})
It("can store int value as provided", func() {
localContext.PutInt("int", 123)
result, _ := localContext.GetInt("int")
Ω(result).Should(Equal(123))
})
It("can store bool value as provided", func() {
localContext.PutBool("key", true)
result, _ := localContext.GetBool("key")
Ω(result).Should(Equal(true))
})
It("can store float64 value as provided", func() {
localContext.PutFloat64("key", float64(3.14))
示例2:
StartRedis("../redis/redis.conf")
var err error
conn, err = redis.Connect("", 63798, "p4ssw0rd")
Ω(err).ShouldNot(HaveOccurred())
workloadCtx = context.New()
})
AfterEach(func() {
StopRedis()
})
Describe("When a single experiment is provided", func() {
Context("When no slaves are running", func() {
It("Times out after a specified time", func() {
worker := NewRedisWorkerWithTimeout(conn, 1)
workloadCtx.PutInt("iterationIndex", 0)
worker.AddWorkloadStep(workloads.Step("timesout", func() error { time.Sleep(10 * time.Second); return nil }, ""))
result := make(chan error)
go func() {
result <- worker.Time("timesout", workloadCtx).Error
}()
Eventually(result, 2).Should(Receive())
})
})
Context("When a slave is running", func() {
var (
slave io.Closer
delegate *LocalWorker
wasCalledWithWorkerIndex int
wasCalledWithWorkerUsername string