util

package
v0.0.0-...-f4ec7ef Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package util is catchall for all utilities that might be used throughout the fullerite code.

iptools.go: It includes functionality to determine the ip address of the machine that's running a fullerite instance.

mesos_leader.go: Detects the leader from amongst a set of mesos masters. It also caches this value for a configurable ttl to save time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExternalIP

func ExternalIP() (string, error)

ExternalIP Provides the string representation of the IP address of the box.

func GetFileSize

func GetFileSize(filePath string) (int64, error)

GetFileSize returns the size in bytes of the specified file

func ParseNerveConfig

func ParseNerveConfig(raw *[]byte) (map[int]string, error)

ParseNerveConfig is responsible for taking the JSON string coming in into a map of service:port it will also filter based on only services runnign on this host. To deal with multi-tenancy we actually will return port:service

Types

type HTTPAlive

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

HTTPAlive implements a simple way of reusing http connections

func (*HTTPAlive) Configure

func (connection *HTTPAlive) Configure(timeout time.Duration,
	aliveDuration time.Duration,
	maxIdleConnections int)

Configure the http connection

func (*HTTPAlive) MakeRequest

func (connection *HTTPAlive) MakeRequest(method string,
	uri string, body io.Reader) (*HTTPAliveResponse, error)

MakeRequest make a new http request

func (*HTTPAlive) SetHeader

func (connection *HTTPAlive) SetHeader(header map[string]string)

SetHeader for setting some custom headers

type HTTPAliveResponse

type HTTPAliveResponse struct {
	StatusCode int
	Body       []byte
	Header     http.Header
}

HTTPAliveResponse returns a response

type MesosLeaderElect

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

MesosLeaderElect Encapsulation for the mesos leader given a set of masters. Cache this so that we don't spend too much time determining the leader every *collector.Collect() call, which happens every 10 seconds.

func (*MesosLeaderElect) Configure

func (mle *MesosLeaderElect) Configure(nodes string, ttl time.Duration)

Configure Provide the set of masters like so ("http://1.2.3.4:5050/,http://5.6.7.8:5050/") and the desired TTL for the cache.

func (*MesosLeaderElect) Get

func (mle *MesosLeaderElect) Get() string

Get get the IP of the leader; calls *MesosLeaderElect.set() on the first call or if the TTL has expired.

type MesosLeaderElectInterface

type MesosLeaderElectInterface interface {
	Configure(string, time.Duration)
	Get() string
	// contains filtered or unexported methods
}

MesosLeaderElectInterface Interface to allow injecting MesosLeaderElect, for easier testing

Jump to

Keyboard shortcuts

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