process

package
v3.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LastContinousCheckHealthy int64
View Source
var ThisHostname string
View Source
var ThisNodeHealth = NewNodeHealth()

Functions

func AcquireAccessToken

func AcquireAccessToken(publicToken string) (secretToken string, err error)

AcquireAccessToken attempts to acquire a hopefully free token; returning in such case the secretToken as proof of ownership.

func AttemptElection

func AttemptElection() (bool, error)

AttemptElection tries to grab leadership (become active node)

func ContinuousRegistration

func ContinuousRegistration(extraInfo string, command string)

ContinuousRegistration will continuously update the node_health table showing that the current process is still running.

func ExpireAccessTokens

func ExpireAccessTokens() error

ExpireAccessTokens removes old, known to be uneligible tokens

func ExpireAvailableNodes

func ExpireAvailableNodes()

ExpireAvailableNodes is an aggressive purging method to remove node entries who have skipped their keepalive for two times.

func ExpireNodesHistory

func ExpireNodesHistory() error

ExpireNodesHistory cleans up the nodes history and is run by the orchestrator active node.

func GenerateAccessToken

func GenerateAccessToken(owner string) (publicToken string, err error)

GenerateAccessToken attempts to generate a new access token and returns the public part of the token

func GetHash

func GetHash(input []byte) string

func GetRandomData

func GetRandomData() []byte

func GrabElection

func GrabElection() error

GrabElection forcibly grabs leadership. Use with care!!

func PrettyUniqueToken

func PrettyUniqueToken() string

func Reelect

func Reelect() error

Reelect clears the way for re-elections. Active node is immediately demoted.

func RegisterNode

func RegisterNode(nodeHealth *NodeHealth) (healthy bool, err error)

func SinceLastGoodHealthCheck

func SinceLastGoodHealthCheck() time.Duration

func SinceLastHealthCheck

func SinceLastHealthCheck() time.Duration

func TokenBelongsToHealthyHttpService

func TokenBelongsToHealthyHttpService(token string) (result bool, err error)

func TokenIsValid

func TokenIsValid(publicToken string, secretToken string) (result bool, err error)

TokenIsValid checks to see whether a given token exists and is not outdated.

func WriteRegisterNode

func WriteRegisterNode(nodeHealth *NodeHealth) (healthy bool, err error)

RegisterNode writes down this node in the node_health table

Types

type HealthStatus

type HealthStatus struct {
	Healthy        bool
	Hostname       string
	Token          string
	IsActiveNode   bool
	ActiveNode     NodeHealth
	Error          error
	AvailableNodes [](*NodeHealth)
}

func HealthTest

func HealthTest() (health *HealthStatus, err error)

HealthTest attempts to write to the backend database and get a result

type NodeHealth

type NodeHealth struct {
	Hostname        string
	Token           string
	AppVersion      string
	FirstSeenActive string
	LastSeenActive  string
	ExtraInfo       string
	Command         string
	DBBackend       string

	LastReported time.Time
	// contains filtered or unexported fields
}

func ElectedNode

func ElectedNode() (node NodeHealth, isElected bool, err error)

ElectedNode returns the details of the elected node, as well as answering the question "is this process the elected one"?

func NewNodeHealth

func NewNodeHealth() *NodeHealth

func ReadAvailableNodes

func ReadAvailableNodes(onlyHttpNodes bool) (nodes [](*NodeHealth), err error)

func (*NodeHealth) Update

func (nodeHealth *NodeHealth) Update() *NodeHealth

type OrchestratorExecutionMode

type OrchestratorExecutionMode string
const (
	OrchestratorExecutionCliMode  OrchestratorExecutionMode = "CLIMode"
	OrchestratorExecutionHttpMode                           = "HttpMode"
)

type Token

type Token struct {
	Hash string
}

Token is used to identify and validate requests to this service

var ProcessToken *Token = NewToken()

func NewToken

func NewToken() *Token

Jump to

Keyboard shortcuts

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