util

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WebhookAnn        = "carrier.ocgi.dev/webhook-config-name"
	ReadinessWebhook  = "ReadinessWebhook"
	DeletableWebhook  = "DeletableWebhook"
	ConstraintWebhook = "ConstraintWebhook"
)

Variables

This section is empty.

Functions

func Bool2Str

func Bool2Str(state bool) string

Bool2Str converts bool to string

func Convert_Carrier_To_GRPC

func Convert_Carrier_To_GRPC(gs *carrierv1.GameServer) *sdkapi.GameServer

Convert_Carrier_To_GRPC converts a K8s GameServer object, into a gRPC SDK GameServer object

func GetContainer

func GetContainer(spec *corev1.PodSpec) *corev1.Container

GetContainer returns the container name

func GetGameServerCondition

GetGameServerCondition returns the condition with the provided type.

func GetWebhookConfigName

func GetWebhookConfigName(gs *carrierv1.GameServer) string

GetWebhookConfigName returns webhook name according to annotations.

func SetGameServerCondition

func SetGameServerCondition(status *carrierv1.GameServerStatus, condition carrierv1.GameServerCondition)

SetGameServerCondition updates the GameServer to include the provided condition. If the condition that we are about to add already exists and has the same status, then we are not going to update.

func SetRequestToGameServerCondition

func SetRequestToGameServerCondition(req SetRequest) (*carrierv1.GameServerCondition, error)

SetRequestToGameServerCondition convert request to GameServer condition

func SetupSignalHandler

func SetupSignalHandler() <-chan struct{}

SetupSignalHandler registered for SIGTERM and SIGINT. A stop channel is returned which is closed on one of these signals. If a second signal is caught, the program is terminated with exit code 1.

func WithExponentialBackoff

func WithExponentialBackoff(initialBackoff time.Duration, webhookFn func() error) error

WithExponentialBackoff will retry webhookFn up to 5 times with exponentially increasing backoff when it returns an error。

Types

type BoolValue

type BoolValue struct {
	Value bool
}

BoolValue for the request only contain bool field, such as SetReady request.

type KeyValue

type KeyValue struct {
	Key   string
	Value string
}

KeyValue for the request contain key/value field, such as SetLabel request.

type SetRequest

type SetRequest struct {
	Type      SetType
	BoolValue *BoolValue
	KeyValue  *KeyValue
}

SetRequest is the request from game server.

type SetType

type SetType string

SetType is set request type

const (
	SetLabel      SetType = "SetLabel"
	SetAnnotation SetType = "SetAnnotation"
	SetCondition  SetType = "SetCondition"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL