utils

package
v0.0.0-...-33bb219 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package utils contains common shared code.

Package utils contains common shared code.

Package utils contains common shared code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvFl64

func EnvFl64(envVar string, defaultVal float64) (val float64)

EnvFl64 gets an environment variable and converts it into a float64

func GetJSON

func GetJSON(url string) (body []byte, err error)

GetJSON makes a GET request to a REST API and returns the JSON response.

func InitWebSocket

func InitWebSocket(apiAddress string) (ws *websocket.Conn, err error)

InitWebSocket opens a websocket connection to the provided address.

func NewKubeClientset

func NewKubeClientset(kubeConfig string, namespace string) (*kubernetes.Clientset, error)

NewKubeClientset creates a Kubernetes clientset for accessing the Kubernetes APIs. Uses the provided kube config file or when running as a pod uses the built in config.

func PutJSON

func PutJSON(url string, payload *bytes.Buffer) (status int, err error)

PutJSON makes a PUT request to a REST API and submits the JSON payload.

Types

type Backoff

type Backoff struct {
	sync.RWMutex
	Factor int

	Min, Max time.Duration
	Timer    *time.Timer
	// contains filtered or unexported fields
}

Backoff holds the number of attempts as well as the min and max backoff delays.

func (*Backoff) Backoff

func (b *Backoff) Backoff(c chan struct{}) error

Backoff calculates the duration and sets an appropriate timer. When it pops it will send on the channel.

func (*Backoff) Reset

func (b *Backoff) Reset()

Reset clears the number of attempts once the API call has succeeded.

func (*Backoff) Stop

func (b *Backoff) Stop()

Stop a backoff timer and mark that we aren't waiting for it any more

func (*Backoff) Waiting

func (b *Backoff) Waiting() bool

Waiting flag is true while waiting for the backoff duration. Prevents any scaling actions.

Jump to

Keyboard shortcuts

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