common

package
v0.0.0-...-519bf1e Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const PingLogMsg = "PING"

Variables

This section is empty.

Functions

func CheckClose

func CheckClose(c io.Closer, err *error)

func DefaultInt64

func DefaultInt64(v int64, defaultVal int64) int64

func EnvVarMap

func EnvVarMap() map[string]string

func ExecInContainer

func ExecInContainer(dockerClient *docker.Client, containerId string, cmd []string) error

func GetOutboundIP

func GetOutboundIP() (net.IP, error)

Get preferred outbound IP of this machine From: https://stackoverflow.com/questions/23558425/how-do-i-get-the-local-ip-address-in-go

func GlobMatches

func GlobMatches(globOrStr string, target string) bool

func ImageExistsLocally

func ImageExistsLocally(dockerClient *docker.Client, imageName string) (bool, error)

func InterpolateWithMap

func InterpolateWithMap(input string, vars map[string]string) string

func IsErrRemovalInProgress

func IsErrRemovalInProgress(err error) bool

func ListMaelstromContainers

func ListMaelstromContainers(dockerClient *docker.Client) ([]types.Container, error)

func MakeSSHKeyPair

func MakeSSHKeyPair(pubKeyPath, privateKeyPath string, keySize int) error

MakeSSHKeyPair make a pair of public and private keys for SSH access. Public key is encoded in the format for inclusion in an OpenSSH authorized_keys file. Private Key generated is PEM encoded keySize is the size of the private key in bytes

func MaxInt64

func MaxInt64(vals ...int64) int64

func MillisToTime

func MillisToTime(millis int64) time.Time

func NewHTTPClientWithSettings

func NewHTTPClientWithSettings(httpSettings HTTPClientSettings) (*http.Client, error)

func NormalizeImageName

func NormalizeImageName(name string) string

func NowMillis

func NowMillis() int64

func ParseEnvVarMap

func ParseEnvVarMap(nvpairs []string) map[string]string

func PullImage

func PullImage(dockerClient *docker.Client, c v1.Component) error

func RemoveContainer

func RemoveContainer(dockerClient *docker.Client, containerId string, componentName string, version string,
	reason string) error

func RemoveMaelstromContainers

func RemoveMaelstromContainers(dockerClient *docker.Client, reason string) (int, error)

func ResolveMaelstromHost

func ResolveMaelstromHost(dockerClient *docker.Client) (string, error)

func SortedMapKeys

func SortedMapKeys(m map[string]string) []string

func StartContainer

func StartContainer(dockerClient *docker.Client, c *v1.Component, maelstromUrl string) (string, error)

func StrTruncate

func StrTruncate(s string, maxlen int) string

func TimeToMillis

func TimeToMillis(t time.Time) int64

func ToIntOrDefault

func ToIntOrDefault(s string, defaultVal int) int

func TruncContainerId

func TruncContainerId(id string) string

func TruncNodeId

func TruncNodeId(id string) string

Types

type ContainerExitedMessage

type ContainerExitedMessage struct {
	ContainerId string
}

type DockerEvent

type DockerEvent struct {
	ImageUpdated    *ImageUpdatedMessage
	ContainerExited *ContainerExitedMessage
}

type DockerImageMonitor

type DockerImageMonitor struct {
	// contains filtered or unexported fields
}

func NewDockerImageMonitor

func NewDockerImageMonitor(dockerClient *docker.Client, observer DockerImageObserver,
	ctx context.Context) *DockerImageMonitor

func (*DockerImageMonitor) RunAsync

func (d *DockerImageMonitor) RunAsync(wg *sync.WaitGroup)

type DockerImageObserver

type DockerImageObserver interface {
	OnDockerEvent(msg DockerEvent)
}

type HTTPClientSettings

type HTTPClientSettings struct {
	ConnectTimeout        time.Duration
	ConnKeepAlive         time.Duration
	ExpectContinue        time.Duration
	IdleConnTimeout       time.Duration
	MaxAllIdleConns       int
	MaxHostIdleConns      int
	ResponseHeaderTimeout time.Duration
	TLSHandshakeTimeout   time.Duration
}

type ImageUpdatedMessage

type ImageUpdatedMessage struct {
	ImageName string
	ImageId   string
}

type LogMsg

type LogMsg struct {
	Component string
	Stream    string
	Data      string
}

func (LogMsg) Format

func (m LogMsg) Format() string

type StringPtr

type StringPtr []*string

func (StringPtr) Len

func (s StringPtr) Len() int

func (StringPtr) Less

func (s StringPtr) Less(i, j int) bool

func (StringPtr) Swap

func (s StringPtr) Swap(i, j int)

Jump to

Keyboard shortcuts

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