当前位置: 首页>>代码示例>>Golang>>正文


Golang receptor.Client类代码示例

本文整理汇总了Golang中github.com/cloudfoundry-incubator/receptor.Client的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Client类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: sshPermissionsFromProcess

func sshPermissionsFromProcess(
	processGuid string,
	index int,
	receptorClient receptor.Client,
	remoteAddr net.Addr,
) (*ssh.Permissions, error) {
	actual, err := receptorClient.ActualLRPByProcessGuidAndIndex(processGuid, index)
	if err != nil {
		return nil, err
	}

	desired, err := receptorClient.GetDesiredLRP(processGuid)
	if err != nil {
		return nil, err
	}

	sshRoute, err := getRoutingInfo(&desired)
	if err != nil {
		return nil, err
	}

	logMessage := fmt.Sprintf("Successful remote access by %s", remoteAddr.String())

	return createPermissions(sshRoute, &actual, desired.LogGuid, logMessage, index)
}
开发者ID:sykesm,项目名称:diego-ssh,代码行数:25,代码来源:diego_proxy_authenticator.go

示例2: TaskStatePoller

func TaskStatePoller(receptorClient receptor.Client, taskGuid string, task *receptor.TaskResponse) func() string {
	return func() string {
		rTask, err := receptorClient.GetTask(taskGuid)
		Expect(err).NotTo(HaveOccurred())

		*task = rTask

		return task.State
	}
}
开发者ID:Gerg,项目名称:inigo,代码行数:10,代码来源:pollers.go

示例3: handleDelete

func handleDelete(receptorClient receptor.Client) {
	if *processGuid == "" {
		logger.Fatal("missing-processGuid", errors.New("Missing mandatory processGuid parameter for delete action"))
	}

	err := receptorClient.DeleteDesiredLRP(*processGuid)
	if err != nil {
		logger.Error("failed-to-delete", err, lager.Data{"process-guid": *processGuid})
		return
	}
	fmt.Printf("Desired LRP successfully deleted for process guid %s\n", *processGuid)
}
开发者ID:davidwadden,项目名称:cf-tcp-router-acceptance-tests,代码行数:12,代码来源:main.go

示例4: LRPInstanceStatePoller

func LRPInstanceStatePoller(receptorClient receptor.Client, processGuid string, index int, lrp *receptor.ActualLRPResponse) func() receptor.ActualLRPState {
	return func() receptor.ActualLRPState {
		lrpInstance, err := receptorClient.ActualLRPByProcessGuidAndIndex(processGuid, index)
		Expect(err).NotTo(HaveOccurred())

		if lrp != nil {
			*lrp = lrpInstance
		}

		return lrpInstance.State
	}
}
开发者ID:Gerg,项目名称:inigo,代码行数:12,代码来源:pollers.go

示例5: ActiveActualLRPs

func ActiveActualLRPs(receptorClient receptor.Client, processGuid string) []receptor.ActualLRPResponse {
	lrps, err := receptorClient.ActualLRPsByProcessGuid(processGuid)
	Expect(err).NotTo(HaveOccurred())

	startedLRPs := make([]receptor.ActualLRPResponse, 0, len(lrps))
	for _, l := range lrps {
		if l.State != receptor.ActualLRPStateUnclaimed {
			startedLRPs = append(startedLRPs, l)
		}
	}

	return startedLRPs
}
开发者ID:Gerg,项目名称:inigo,代码行数:13,代码来源:pollers.go

示例6: handleScale

func handleScale(receptorClient receptor.Client) {
	if *processGuid == "" {
		logger.Fatal("missing-processGuid", errors.New("Missing mandatory processGuid parameter for scale action"))
	}

	updatePayload := receptor.DesiredLRPUpdateRequest{
		Instances: numberOfInstances,
	}
	err := receptorClient.UpdateDesiredLRP(*processGuid, updatePayload)
	if err != nil {
		logger.Error("failed-to-scale", err, lager.Data{"process-guid": *processGuid, "update-request": updatePayload})
		return
	}
	fmt.Printf("LRP %s scaled to number of instances %d\n", *processGuid, *numberOfInstances)
}
开发者ID:davidwadden,项目名称:cf-tcp-router-acceptance-tests,代码行数:15,代码来源:main.go

示例7: LRPStatePoller

func LRPStatePoller(receptorClient receptor.Client, processGuid string, lrp *receptor.ActualLRPResponse) func() receptor.ActualLRPState {
	return func() receptor.ActualLRPState {
		lrps, err := receptorClient.ActualLRPsByProcessGuid(processGuid)
		Expect(err).NotTo(HaveOccurred())

		if len(lrps) == 0 {
			return receptor.ActualLRPStateInvalid
		}

		if lrp != nil {
			*lrp = lrps[0]
		}

		return lrps[0].State
	}
}
开发者ID:Gerg,项目名称:inigo,代码行数:16,代码来源:pollers.go

示例8: handleCreate

func handleCreate(receptorClient receptor.Client) {
	newProcessGuid, err := uuid.NewV4()
	if err != nil {
		logger.Error("failed-generate-guid", err)
		return
	}
	route := tcpRoute{
		ExternalPort:  uint16(*externalPort),
		ContainerPort: uint16(*containerPort),
	}
	routes := []tcpRoute{route}
	data, err := json.Marshal(routes)
	if err != nil {
		logger.Error("failed-to-marshal", err)
		return
	}
	routingInfo := json.RawMessage(data)
	lrp := receptor.DesiredLRPCreateRequest{
		ProcessGuid: newProcessGuid.String(),
		LogGuid:     "log-guid",
		Domain:      "ge",
		Instances:   1,
		Setup: &models.SerialAction{
			Actions: []models.Action{
				&models.RunAction{
					Path: "sh",
					User: "vcap",
					Args: []string{
						"-c",
						"curl https://s3.amazonaws.com/router-release-blobs/tcp-sample-receiver.linux -o /tmp/tcp-sample-receiver && chmod +x /tmp/tcp-sample-receiver",
					},
				},
			},
		},
		Action: &models.ParallelAction{
			Actions: []models.Action{
				&models.RunAction{
					Path: "sh",
					User: "vcap",
					Args: []string{
						"-c",
						fmt.Sprintf("/tmp/tcp-sample-receiver -address 0.0.0.0:%d -serverId %s", *containerPort, *serverId),
						// fmt.Sprintf("nc -l -k %d > /tmp/output", *containerPort),
					},
				},
			},
		},
		Monitor: &models.RunAction{
			Path: "sh",
			User: "vcap",
			Args: []string{
				"-c",
				fmt.Sprintf("nc -z 0.0.0.0 %d", *containerPort),
			}},
		StartTimeout: 60,
		RootFS:       "preloaded:cflinuxfs2",
		MemoryMB:     128,
		DiskMB:       128,
		Ports:        []uint16{uint16(*containerPort)},
		Routes: receptor.RoutingInfo{
			"tcp-router": &routingInfo,
		},
		EgressRules: []models.SecurityGroupRule{
			{
				Protocol:     models.TCPProtocol,
				Destinations: []string{"0.0.0.0-255.255.255.255"},
				Ports:        []uint16{80, 443},
			},
			{
				Protocol:     models.UDPProtocol,
				Destinations: []string{"0.0.0.0/0"},
				PortRange: &models.PortRange{
					Start: 53,
					End:   53,
				},
			},
		},
	}
	err = receptorClient.CreateDesiredLRP(lrp)
	if err != nil {
		logger.Error("failed-create", err, lager.Data{"LRP": lrp})
	} else {
		fmt.Printf("Successfully created LRP with process guid %s\n", newProcessGuid)
	}
}
开发者ID:davidwadden,项目名称:cf-tcp-router-acceptance-tests,代码行数:85,代码来源:main.go

示例9: UpsertInigoDomain

func UpsertInigoDomain(receptorClient receptor.Client) {
	err := receptorClient.UpsertDomain(defaultDomain, 0)
	Expect(err).NotTo(HaveOccurred())
}
开发者ID:Gerg,项目名称:inigo,代码行数:4,代码来源:receptor_requests.go

示例10:

			}, 20*time.Second, 1*time.Second).ShouldNot(HaveOccurred())

			conn1, response1 := sendAndReceive(address)
			conn2, response2 := sendAndReceive(address)
			Expect(response1).ShouldNot(Equal(response2))

			err := conn1.Close()
			Expect(err).ShouldNot(HaveOccurred())
			err = conn2.Close()
			Expect(err).ShouldNot(HaveOccurred())
		})
	})

	Describe("LRP with TCP routing requirements is desired", func() {
		var (
			receptorClient receptor.Client
			processGuid    string
		)

		BeforeEach(func() {

			receptorClient = receptor.NewClient(routerApiConfig.DiegoAPIURL)

			externalPort = 62000 + GinkgoParallelNode()
			sampleReceiverPort1 = 8000 + GinkgoParallelNode()
			serverId1 = fmt.Sprintf("serverId-%d", GinkgoParallelNode())

			lrp := helpers.CreateDesiredLRP(logger,
				uint16(externalPort), uint16(sampleReceiverPort1), serverId1, 1)

			err := receptorClient.CreateDesiredLRP(lrp)
			Expect(err).ShouldNot(HaveOccurred())
开发者ID:davidwadden,项目名称:cf-tcp-router-acceptance-tests,代码行数:32,代码来源:router_test.go


注:本文中的github.com/cloudfoundry-incubator/receptor.Client类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。