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


Golang Probe.Handler方法代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/api.Probe.Handler方法的典型用法代碼示例。如果您正苦於以下問題:Golang Probe.Handler方法的具體用法?Golang Probe.Handler怎麽用?Golang Probe.Handler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在k8s/io/kubernetes/pkg/api.Probe的用法示例。


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

示例1: updateProbe

// updateProbe updates only those fields with flags set by the user
func (o *ProbeOptions) updateProbe(probe *kapi.Probe) {
	switch {
	case o.Command != nil:
		probe.Handler = kapi.Handler{Exec: &kapi.ExecAction{Command: o.Command}}
	case o.HTTPGetAction != nil:
		probe.Handler = kapi.Handler{HTTPGet: o.HTTPGetAction}
	case len(o.OpenTCPSocket) > 0:
		probe.Handler = kapi.Handler{TCPSocket: &kapi.TCPSocketAction{Port: intOrString(o.OpenTCPSocket)}}
	}
	if o.InitialDelaySeconds != nil {
		probe.InitialDelaySeconds = int32(*o.InitialDelaySeconds)
	}
	if o.SuccessThreshold != nil {
		probe.SuccessThreshold = int32(*o.SuccessThreshold)
	}
	if o.FailureThreshold != nil {
		probe.FailureThreshold = int32(*o.FailureThreshold)
	}
	if o.TimeoutSeconds != nil {
		probe.TimeoutSeconds = int32(*o.TimeoutSeconds)
	}
	if o.PeriodSeconds != nil {
		probe.PeriodSeconds = int32(*o.PeriodSeconds)
	}
}
開發者ID:sgallagher,項目名稱:origin,代碼行數:26,代碼來源:probe.go

示例2: setTestProbe

func setTestProbe(pod *api.Pod, probeType probeType, probeSpec api.Probe) {
	// All tests rely on the fake exec prober.
	probeSpec.Handler = api.Handler{
		Exec: &api.ExecAction{},
	}

	// Apply test defaults, overwridden for test speed.
	defaults := map[string]int64{
		"TimeoutSeconds":   1,
		"PeriodSeconds":    1,
		"SuccessThreshold": 1,
		"FailureThreshold": 1,
	}
	for field, value := range defaults {
		f := reflect.ValueOf(&probeSpec).Elem().FieldByName(field)
		if f.Int() == 0 {
			f.SetInt(value)
		}
	}

	switch probeType {
	case readiness:
		pod.Spec.Containers[0].ReadinessProbe = &probeSpec
	case liveness:
		pod.Spec.Containers[0].LivenessProbe = &probeSpec
	}
}
開發者ID:ethernetdan,項目名稱:kubernetes,代碼行數:27,代碼來源:testing.go

示例3: newTestWorker

func newTestWorker(m *manager, probeType probeType, probeSpec api.Probe) *worker {
	// All tests rely on the fake exec prober.
	probeSpec.Handler = api.Handler{
		Exec: &api.ExecAction{},
	}

	pod := getTestPod(probeType, probeSpec)
	return newWorker(m, probeType, &pod, pod.Spec.Containers[0])
}
開發者ID:pologood,項目名稱:kubernetes,代碼行數:9,代碼來源:worker_test.go

示例4: getTestPod

func getTestPod(probeType probeType, probeSpec api.Probe) api.Pod {
	container := api.Container{
		Name: testContainerName,
	}

	// All tests rely on the fake exec prober.
	probeSpec.Handler = api.Handler{
		Exec: &api.ExecAction{},
	}

	// Apply test defaults, overwridden for test speed.
	defaults := map[string]int64{
		"TimeoutSeconds":   1,
		"PeriodSeconds":    1,
		"SuccessThreshold": 1,
		"FailureThreshold": 1,
	}
	for field, value := range defaults {
		f := reflect.ValueOf(&probeSpec).Elem().FieldByName(field)
		if f.Int() == 0 {
			f.SetInt(value)
		}
	}

	switch probeType {
	case readiness:
		container.ReadinessProbe = &probeSpec
	case liveness:
		container.LivenessProbe = &probeSpec
	}
	pod := api.Pod{
		Spec: api.PodSpec{
			Containers:    []api.Container{container},
			RestartPolicy: api.RestartPolicyNever,
		},
	}
	pod.Name = "testPod"
	pod.UID = testPodUID
	return pod
}
開發者ID:johndmulhausen,項目名稱:kubernetes,代碼行數:40,代碼來源:testing.go

示例5: newTestWorker

func newTestWorker(m *manager, probeType probeType, probeSpec api.Probe) *worker {
	// All tests rely on the fake exec prober.
	probeSpec.Handler = api.Handler{
		Exec: &api.ExecAction{},
	}
	// Apply default values.
	defaults := map[string]int64{
		"TimeoutSeconds":   1,
		"PeriodSeconds":    10,
		"SuccessThreshold": 1,
		"FailureThreshold": 3,
	}
	for field, value := range defaults {
		f := reflect.ValueOf(&probeSpec).Elem().FieldByName(field)
		if f.Int() == 0 {
			f.SetInt(value)
		}
	}

	pod := getTestPod(probeType, probeSpec)
	return newWorker(m, probeType, &pod, pod.Spec.Containers[0])
}
開發者ID:njcaruso,項目名稱:kubernetes,代碼行數:22,代碼來源:worker_test.go


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