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


Golang container.Container類代碼示例

本文整理匯總了Golang中github.com/marmelab/gaudi/container.Container的典型用法代碼示例。如果您正苦於以下問題:Golang Container類的具體用法?Golang Container怎麽用?Golang Container使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: extendsOne

func extendsOne(child, parent *container.Container, extendsChan map[string]chan bool) {
	// Waiting for dependencies to be extended
	<-extendsChan[parent.Name]

	// Extends the application
	child.ExtendsContainer(parent)
	close(extendsChan[child.Name])
}
開發者ID:hungld,項目名稱:gaudi,代碼行數:8,代碼來源:gaudi.go

示例2: startContainer

func (maestro *Maestro) startContainer(currentContainer *container.Container, done map[string]chan bool) {
	// Waiting for dependencies to start
	for _, dependency := range currentContainer.Dependencies {
		<-done[dependency.Name]
	}

	currentContainer.Start()

	close(done[currentContainer.Name])
}
開發者ID:pborreli,項目名稱:gaudi,代碼行數:10,代碼來源:maestro.go

示例3: TestGetFirstPortShouldReturnTheFirstDeclaredPort

func (s *ContainerTestSuite) TestGetFirstPortShouldReturnTheFirstDeclaredPort(c *C) {
	container := container.Container{Name: "Test"}

	c.Check(container.GetFirstPort(), Equals, "")

	container.Ports = make(map[string]string)
	container.Ports["80"] = "8080"
	container.Ports["9000"] = "9000"

	c.Check(container.GetFirstPort(), Equals, "80")
}
開發者ID:hungld,項目名稱:gaudi,代碼行數:11,代碼來源:container_test.go

示例4: startOne

func startOne(currentContainer *container.Container, rebuild bool, done map[string]chan bool) {
	// Waiting for dependencies to be started
	for _, dependency := range currentContainer.Dependencies {
		if dependency.Name == currentContainer.Name {
			util.LogError("Application " + currentContainer.Name + " can't be linked with itself.")
		}

		<-done[dependency.Name]
	}

	currentContainer.Start(rebuild)

	close(done[currentContainer.Name])
}
開發者ID:hungld,項目名稱:gaudi,代碼行數:14,代碼來源:containerCollection.go

示例5: TestStartedApplicationShouldRetrieveItsIp

func (s *ContainerTestSuite) TestStartedApplicationShouldRetrieveItsIp(c *C) {
	// Create a gomock controller, and arrange for it's finish to be called
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()

	// Setup the docker mock package
	docker.MOCK().SetController(ctrl)
	docker.EXPECT().Start(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("123")
	docker.EXPECT().Inspect(gomock.Any()).Return([]byte("[{\"ID\": \"123\", \"State\":{\"Running\": true}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil)

	// @TODO : find a way to mock time.Sleep
	container := container.Container{Name: "Test"}
	container.Start(true)

	c.Check(container.IsRunning(), Equals, true)
	c.Check(container.Ip, Equals, "172.17.0.10")
}
開發者ID:hungld,項目名稱:gaudi,代碼行數:17,代碼來源:container_test.go

示例6: TestCallCleanShouldStopTheContainer

func (s *ContainerTestSuite) TestCallCleanShouldStopTheContainer(c *C) {
	// Create a gomock controller, and arrange for it's finish to be called
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()

	// Setup the docker mock package
	docker.MOCK().SetController(ctrl)
	docker.EXPECT().Inspect(gomock.Any()).Return([]byte("[{\"ID\": \"123\", \"State\":{\"Running\": false}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil)
	docker.EXPECT().Kill(gomock.Any()).Return()
	docker.EXPECT().Remove(gomock.Any()).Return()

	done := make(chan bool, 1)
	container := container.Container{Name: "Test"}
	container.Clean(done)
	<-done

	c.Check(container.IsRunning(), Equals, false)
}
開發者ID:hungld,項目名稱:gaudi,代碼行數:18,代碼來源:container_test.go

示例7: TestContainerWithReadyDependenciesShouldBeReady

func (s *ContainerTestSuite) TestContainerWithReadyDependenciesShouldBeReady(c *C) {
	dep1 := container.Container{Name: "abc"}
	dep1.Running = false

	dep2 := container.Container{Name: "abc"}
	dep2.Running = true

	mainContainer := container.Container{Name: "Test"}
	mainContainer.Dependencies = make([]*container.Container, 0)

	mainContainer.AddDependency(&dep1)
	mainContainer.AddDependency(&dep2)

	c.Check(mainContainer.IsReady(), Equals, false)

	dep1.Running = true
	c.Check(mainContainer.IsReady(), Equals, true)
}
開發者ID:hungld,項目名稱:gaudi,代碼行數:18,代碼來源:container_test.go


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