本文整理汇总了Golang中github.com/cloudfoundry-incubator/bbs/models.Task类的典型用法代码示例。如果您正苦于以下问题:Golang Task类的具体用法?Golang Task怎么用?Golang Task使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Task类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: prettyPrint
func prettyPrint(encrypted []byte, key string, label string) {
var decrypted, err = decrypt(encrypted, key, label)
if err != nil {
return
}
var model1 models.DesiredLRPRunInfo
err = model1.Unmarshal(decrypted)
if err != nil {
// NOP
} else {
pretty.Println(model1)
return
}
var model2 models.DesiredLRPSchedulingInfo
err = model2.Unmarshal(decrypted)
if err != nil {
// NOP
} else {
pretty.Println(model2)
return
}
var model3 models.ActualLRP
err = model3.Unmarshal(decrypted)
if err != nil {
// NOP
} else {
pretty.Println(model3)
return
}
var model4 models.Task
err = model4.Unmarshal(decrypted)
if err != nil {
// NOP
} else {
pretty.Println(model4)
return
}
var model5 models.DesiredLRP
err = model5.Unmarshal(decrypted)
if err != nil {
log.Println("Unknown data type: ", string(decrypted))
} else {
pretty.Println(model5)
return
}
}
开发者ID:kei-yamazaki,项目名称:bbsDecryptor,代码行数:52,代码来源:main.go
示例2:
fakeServer = ghttp.NewServer()
logger = lagertest.NewTestLogger("test")
logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.INFO))
})
AfterEach(func() {
fakeServer.Close()
})
Describe("HandleCompletedTask", func() {
var (
callbackURL string
taskDB *dbfakes.FakeTaskDB
statusCodes chan int
reqCount chan struct{}
task *models.Task
httpClient *http.Client
)
BeforeEach(func() {
httpClient = cf_http.NewClient()
statusCodes = make(chan int)
reqCount = make(chan struct{})
fakeServer.RouteToHandler("POST", "/the-callback/url", func(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(<-statusCodes)
})
callbackURL = fakeServer.URL() + "/the-callback/url"
开发者ID:timani,项目名称:bbs,代码行数:31,代码来源:taskcallback_test.go
示例3: demoteToCompleted
func demoteToCompleted(task *models.Task) *models.Task {
task.State = models.Task_Completed
return task
}
开发者ID:emc-xchallenge,项目名称:bbs,代码行数:4,代码来源:task_convergence.go
示例4:
Context("when the rootfs is not preloaded", func() {
BeforeEach(func() {
desiredLRP.RootFs = "docker://cloudfoundry/test"
})
It("uses TotalDiskLimit as the disk scope", func() {
runReq, err := rep.NewRunRequestFromDesiredLRP(containerGuid, desiredLRP, &actualLRP.ActualLRPKey, &actualLRP.ActualLRPInstanceKey)
Expect(err).NotTo(HaveOccurred())
Expect(runReq.DiskScope).To(Equal(executor.TotalDiskLimit))
})
})
})
Describe("NewRunRequestFromTask", func() {
var task *models.Task
BeforeEach(func() {
task = model_helpers.NewValidTask("task-guid")
task.RootFs = "preloaded://rootfs"
})
It("returns a valid run request", func() {
runReq, err := rep.NewRunRequestFromTask(task)
Expect(err).NotTo(HaveOccurred())
Expect(runReq.Tags).To(Equal(executor.Tags{
rep.ResultFileTag: task.ResultFile,
}))
Expect(runReq.RunInfo).To(Equal(executor.RunInfo{
DiskScope: executor.ExclusiveDiskLimit,
CPUWeight: uint(task.CpuWeight),
开发者ID:jianhuiz,项目名称:rep,代码行数:30,代码来源:conversion_helpers_test.go
示例5: TaskSchemaPath
func TaskSchemaPath(task *models.Task) string {
return TaskSchemaPathByGuid(task.GetTaskGuid())
}
开发者ID:timani,项目名称:bbs,代码行数:3,代码来源:etcd_db.go
示例6:
package models_test
import (
"strings"
"time"
"github.com/cloudfoundry-incubator/bbs/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Task", func() {
var taskPayload string
var task models.Task
BeforeEach(func() {
taskPayload = `{
"task_guid":"some-guid",
"domain":"some-domain",
"rootfs": "docker:///docker.com/docker",
"env":[
{
"name":"ENV_VAR_NAME",
"value":"an environmment value"
}
],
"cell_id":"cell",
"action": {
"download":{
"from":"old_location",
"to":"new_location",
开发者ID:emc-xchallenge,项目名称:bbs,代码行数:31,代码来源:task_test.go
示例7:
import (
"encoding/json"
"strings"
"time"
"github.com/cloudfoundry-incubator/bbs/format"
"github.com/cloudfoundry-incubator/bbs/models"
"github.com/gogo/protobuf/proto"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Task", func() {
var taskPayload string
var task models.Task
BeforeEach(func() {
taskPayload = `{
"task_guid":"some-guid",
"domain":"some-domain",
"rootfs": "docker:///docker.com/docker",
"env":[
{
"name":"ENV_VAR_NAME",
"value":"an environmment value"
}
],
"cell_id":"cell",
"action": {
"download":{
开发者ID:timani,项目名称:bbs,代码行数:30,代码来源:task_test.go
示例8:
"github.com/cloudfoundry-incubator/bbs/models/test/model_helpers"
"github.com/cloudfoundry-incubator/rep"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/pivotal-golang/lager/lagertest"
)
var _ = Describe("Task Handlers", func() {
var (
logger *lagertest.TestLogger
fakeTaskDB *dbfakes.FakeTaskDB
fakeAuctioneerClient *auctioneerfakes.FakeClient
responseRecorder *httptest.ResponseRecorder
exitCh chan struct{}
handler *handlers.TaskHandler
task1 models.Task
task2 models.Task
requestBody interface{}
)
BeforeEach(func() {
fakeTaskDB = new(dbfakes.FakeTaskDB)
fakeAuctioneerClient = new(auctioneerfakes.FakeClient)
logger = lagertest.NewTestLogger("test")
responseRecorder = httptest.NewRecorder()
exitCh = make(chan struct{}, 1)
handler = handlers.NewTaskHandler(logger, fakeTaskDB, nil, fakeAuctioneerClient, fakeServiceClient, fakeRepClientFactory, exitCh)
})
开发者ID:timani,项目名称:bbs,代码行数:32,代码来源:task_handlers_deprecated_test.go
示例9:
Describe("Version", func() {
It("returns the timestamp from which it was created", func() {
Expect(migration.Version()).To(BeEquivalentTo(1451635200))
})
})
Describe("Down", func() {
It("returns a not implemented error", func() {
Expect(migration.Down(logger)).To(HaveOccurred())
})
})
Describe("Up", func() {
var (
task *models.Task
migrationErr error
)
Describe("Task Migration", func() {
BeforeEach(func() {
task = model_helpers.NewValidTask("task-guid-1")
task.Action = models.WrapAction(&models.TimeoutAction{Action: model_helpers.NewValidAction(),
DeprecatedTimeoutNs: 5 * int64(time.Second),
})
})
JustBeforeEach(func() {
taskData, err := serializer.Marshal(logger, format.ENCRYPTED_PROTO, task)
Expect(err).NotTo(HaveOccurred())
_, err = storeClient.Set(etcddb.TaskSchemaPath(task), taskData, 0)
Expect(err).NotTo(HaveOccurred())
开发者ID:timani,项目名称:bbs,代码行数:31,代码来源:1451635200_timeouts_to_milliseconds_test.go
示例10:
responseRecorder *httptest.ResponseRecorder
handler *handlers.TaskHandler
request *http.Request
)
BeforeEach(func() {
fakeClient = &fake_bbs.FakeClient{}
logger = lager.NewLogger("test")
logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG))
responseRecorder = httptest.NewRecorder()
handler = handlers.NewTaskHandler(fakeClient, logger)
})
Describe("Create", func() {
var validCreateRequest receptor.TaskCreateRequest
var expectedTask *models.Task
BeforeEach(func() {
validCreateRequest = receptor.TaskCreateRequest{
TaskGuid: "task-guid-1",
Domain: "test-domain",
RootFS: "docker://docker",
Action: models.WrapAction(&models.RunAction{User: "me", Path: "/bin/bash", Args: []string{"echo", "hi"}}),
MemoryMB: 24,
DiskMB: 12,
CPUWeight: 10,
LogGuid: "guid",
LogSource: "source-name",
ResultFile: "result-file",
Annotation: "some annotation",
Privileged: true,
开发者ID:davidwadden,项目名称:lattice-release,代码行数:31,代码来源:task_handlers_test.go
示例11:
package serialization_test
import (
"github.com/cloudfoundry-incubator/bbs/models"
"github.com/cloudfoundry-incubator/receptor"
"github.com/cloudfoundry-incubator/receptor/serialization"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Task Serialization", func() {
Describe("TaskToResponse", func() {
var task *models.Task
BeforeEach(func() {
task = &models.Task{
TaskGuid: "the-task-guid",
Domain: "the-domain",
CellId: "the-cell-id",
CreatedAt: 1234,
FailureReason: "the-failure-reason",
Failed: true,
Result: "the-result",
State: models.Task_Invalid,
TaskDefinition: &models.TaskDefinition{
RootFs: "the-rootfs",
Action: models.WrapAction(&models.UploadAction{
From: "from",
To: "to",
}),
开发者ID:davidwadden,项目名称:lattice-release,代码行数:31,代码来源:tasks_test.go
注:本文中的github.com/cloudfoundry-incubator/bbs/models.Task类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论