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


Golang models.Task類代碼示例

本文整理匯總了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;未經允許,請勿轉載。