maelstrom

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: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseProjectYaml

func ParseProjectYaml(yamlStr string, strict bool) (v1.Project, error)

func ParseYamlFileAndInterpolateEnv

func ParseYamlFileAndInterpolateEnv(fname string, strict bool) (v1.Project, error)

func PutProjectOutputEmpty

func PutProjectOutputEmpty(out v1.PutProjectOutput) bool

Types

type AwsLifecycleHookMessage

type AwsLifecycleHookMessage struct {
	QueueUrl             string
	MessageReceiptHandle string
	AccountId            string
	RequestId            string
	Time                 string
	Service              string
	AutoScalingGroupName string
	EC2InstanceId        string
	LifecycleActionToken string
	LifecycleHookName    string
}

func (*AwsLifecycleHookMessage) ToAwsLifecycleHook

func (h *AwsLifecycleHookMessage) ToAwsLifecycleHook() *v1.AwsLifecycleHook

func (*AwsLifecycleHookMessage) TryParseAge

func (h *AwsLifecycleHookMessage) TryParseAge() *time.Duration

type AwsSpotInstanceAction

type AwsSpotInstanceAction struct {
	Action string
	Time   string
}

type CalcAutoscaleInput

type CalcAutoscaleInput struct {
	Nodes            []v1.NodeStatus
	ComponentsByName map[string]v1.Component
}

type Cluster

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

func NewCluster

func NewCluster(myNodeId string, localNodeService v1.NodeService) *Cluster

func (*Cluster) AddObserver

func (c *Cluster) AddObserver(observer ClusterObserver)

func (*Cluster) BroadcastDataChanged

func (c *Cluster) BroadcastDataChanged(input v1.NotifyDataChangedInput)

func (*Cluster) BroadcastTerminationEvent

func (c *Cluster) BroadcastTerminationEvent(input v1.TerminateNodeInput)

func (*Cluster) GetMaelstromService

func (c *Cluster) GetMaelstromService(node v1.NodeStatus) v1.MaelstromService

func (*Cluster) GetMaelstromServiceWithTimeout

func (c *Cluster) GetMaelstromServiceWithTimeout(node v1.NodeStatus, timeout time.Duration) v1.MaelstromService

func (*Cluster) GetNodeById

func (c *Cluster) GetNodeById(nodeId string) *v1.NodeStatus

func (*Cluster) GetNodeService

func (c *Cluster) GetNodeService(node v1.NodeStatus) v1.NodeService

func (*Cluster) GetNodeServiceById

func (c *Cluster) GetNodeServiceById(nodeId string) v1.NodeService

func (*Cluster) GetNodeServiceWithTimeout

func (c *Cluster) GetNodeServiceWithTimeout(node v1.NodeStatus, timeout time.Duration) v1.NodeService

func (*Cluster) GetNodes

func (c *Cluster) GetNodes() []v1.NodeStatus

func (*Cluster) GetRemoteMaelstromServices

func (c *Cluster) GetRemoteMaelstromServices() []v1.MaelstromService

func (*Cluster) GetRemoteNodeServices

func (c *Cluster) GetRemoteNodeServices() []v1.NodeService

func (*Cluster) RemoveAndBroadcast

func (c *Cluster) RemoveAndBroadcast()

func (*Cluster) RemoveNode

func (c *Cluster) RemoveNode(nodeId string) bool

func (*Cluster) SetAllNodes

func (c *Cluster) SetAllNodes(nodes []v1.NodeStatus)

func (*Cluster) SetAndBroadcastStatus

func (c *Cluster) SetAndBroadcastStatus(node v1.NodeStatus)

func (*Cluster) SetLocalMaelstromService

func (c *Cluster) SetLocalMaelstromService(svc v1.MaelstromService)

func (*Cluster) SetNode

func (c *Cluster) SetNode(node v1.NodeStatus) bool

type ClusterObserver

type ClusterObserver interface {
	OnClusterUpdated(nodes map[string]v1.NodeStatus)
}

type ComponentInfoByRunningCountAndReqTime

type ComponentInfoByRunningCountAndReqTime struct {
	Components     []v1.ComponentInfo
	InstanceCounts map[string]int
}

func (ComponentInfoByRunningCountAndReqTime) Len

func (ComponentInfoByRunningCountAndReqTime) Less

func (ComponentInfoByRunningCountAndReqTime) Swap

type ComponentResolver

type ComponentResolver interface {
	ByName(componentName string) (v1.Component, error)
	ByHTTPRequest(req *http.Request, public bool) (v1.Component, error)
}

type ComponentSubscriber

type ComponentSubscriber interface {
	OnComponentNotification(change v1.DataChangedUnion)
}

type ComponentTargetByCompName

type ComponentTargetByCompName []v1.ComponentTarget

func (ComponentTargetByCompName) Len

func (ComponentTargetByCompName) Less

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

func (ComponentTargetByCompName) Swap

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

type DbComponentResolver

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

func NewDbResolver

func NewDbResolver(db db.Db, certWrapper *cert.CertMagicWrapper, cacheDuration time.Duration) *DbComponentResolver

func (*DbComponentResolver) ByHTTPRequest

func (r *DbComponentResolver) ByHTTPRequest(req *http.Request, public bool) (v1.Component, error)

func (*DbComponentResolver) ByName

func (r *DbComponentResolver) ByName(componentName string) (comp v1.Component, err error)

func (*DbComponentResolver) OnComponentNotification

func (r *DbComponentResolver) OnComponentNotification(cn v1.DataChangedUnion)

type DockerPruner

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

func NewDockerPruner

func NewDockerPruner(dockerClient *docker.Client, db db.Db, ctx context.Context,
	pruneUnregistered bool, pruneKeep []string) *DockerPruner

func (*DockerPruner) Run

func (d *DockerPruner) Run(interval time.Duration, wg *sync.WaitGroup)

type DurationAscend

type DurationAscend []time.Duration

func (DurationAscend) Len

func (s DurationAscend) Len() int

func (DurationAscend) Less

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

func (DurationAscend) Swap

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

type ErrorCode

type ErrorCode int
const (
	MiscError ErrorCode = -32000
	DbError             = -32001
)

type Gateway

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

func NewGateway

func NewGateway(r ComponentResolver, routerReg *router.Registry, public bool,
	myIpAddr string) *Gateway

func (*Gateway) Route

func (g *Gateway) Route(rw http.ResponseWriter, req *http.Request, comp *v1.Component, publicGateway bool)

func (*Gateway) ServeHTTP

func (g *Gateway) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type ImagePuller

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

func NewImagePuller

func NewImagePuller(dockerClient *docker.Client, db db.Db, pullState *PullState) *ImagePuller

func (*ImagePuller) OnComponentNotification

func (i *ImagePuller) OnComponentNotification(change v1.DataChangedUnion)

type LogsHandler

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

func NewLogsHandler

func NewLogsHandler(dockerClient *docker.Client) *LogsHandler

func (*LogsHandler) ServeHTTP

func (h *LogsHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type MaelServiceImpl

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

func NewMaelServiceImpl

func NewMaelServiceImpl(db db.Db, componentSubscribers []ComponentSubscriber, certWrapper *cert.CertMagicWrapper,
	myNodeId string, cluster *Cluster) *MaelServiceImpl

func (*MaelServiceImpl) GetComponent

func (v *MaelServiceImpl) GetComponent(input v1.GetComponentInput) (v1.GetComponentOutput, error)

func (*MaelServiceImpl) GetEventSource

func (v *MaelServiceImpl) GetEventSource(input v1.GetEventSourceInput) (v1.GetEventSourceOutput, error)

func (*MaelServiceImpl) GetProject

func (v *MaelServiceImpl) GetProject(input v1.GetProjectInput) (v1.GetProjectOutput, error)

func (*MaelServiceImpl) ListComponents

func (v *MaelServiceImpl) ListComponents(input v1.ListComponentsInput) (v1.ListComponentsOutput, error)

func (*MaelServiceImpl) ListEventSources

func (*MaelServiceImpl) ListProjects

func (v *MaelServiceImpl) ListProjects(input v1.ListProjectsInput) (v1.ListProjectsOutput, error)

func (*MaelServiceImpl) NotifyDataChanged

func (*MaelServiceImpl) PutComponent

func (v *MaelServiceImpl) PutComponent(input v1.PutComponentInput) (v1.PutComponentOutput, error)

func (*MaelServiceImpl) PutEventSource

func (v *MaelServiceImpl) PutEventSource(input v1.PutEventSourceInput) (v1.PutEventSourceOutput, error)

func (*MaelServiceImpl) PutProject

func (v *MaelServiceImpl) PutProject(input v1.PutProjectInput) (v1.PutProjectOutput, error)

func (*MaelServiceImpl) RemoveComponent

func (*MaelServiceImpl) RemoveEventSource

func (*MaelServiceImpl) RemoveProject

func (v *MaelServiceImpl) RemoveProject(input v1.RemoveProjectInput) (v1.RemoveProjectOutput, error)

func (*MaelServiceImpl) ToggleEventSources

type NodeServiceImpl

type NodeServiceImpl struct {

	// if node.observedAt is older than this duration we'll consider it stale and remove it
	NodeLiveness time.Duration
	// contains filtered or unexported fields
}

func NewNodeServiceImplFromDocker

func NewNodeServiceImplFromDocker(db db.Db, dockerClient *docker.Client, privatePort int,
	peerUrl string, totalMemAllowed int64, instanceId string, shutdownCh chan ShutdownFunc,
	awsSession *session.Session, terminateCommand string, pullState *PullState) (*NodeServiceImpl, error)

func (*NodeServiceImpl) Cluster

func (n *NodeServiceImpl) Cluster() *Cluster

func (*NodeServiceImpl) GetConvergeRegistry

func (n *NodeServiceImpl) GetConvergeRegistry() *converge.Registry

func (*NodeServiceImpl) GetStatus

func (*NodeServiceImpl) ListNodeStatus

func (n *NodeServiceImpl) ListNodeStatus(input v1.ListNodeStatusInput) (v1.ListNodeStatusOutput, error)

func (*NodeServiceImpl) LogPairs

func (n *NodeServiceImpl) LogPairs() []interface{}

func (*NodeServiceImpl) NodeId

func (n *NodeServiceImpl) NodeId() string

func (*NodeServiceImpl) OnClusterUpdated

func (n *NodeServiceImpl) OnClusterUpdated(nodes map[string]v1.NodeStatus)

func (*NodeServiceImpl) OnContainersChanged

func (n *NodeServiceImpl) OnContainersChanged()

func (*NodeServiceImpl) PlaceComponent

func (n *NodeServiceImpl) PlaceComponent(input v1.PlaceComponentInput) (v1.PlaceComponentOutput, error)

func (*NodeServiceImpl) RunAutoscaleLoop

func (n *NodeServiceImpl) RunAutoscaleLoop(interval time.Duration, ctx context.Context, wg *sync.WaitGroup)

func (*NodeServiceImpl) RunAwsAutoScaleTerminatePollerLoop

func (n *NodeServiceImpl) RunAwsAutoScaleTerminatePollerLoop(queueUrl string, maxAgeSeconds int,
	ctx context.Context, wg *sync.WaitGroup)

func (*NodeServiceImpl) RunAwsSpotTerminatePollerLoop

func (n *NodeServiceImpl) RunAwsSpotTerminatePollerLoop(interval time.Duration, ctx context.Context,
	wg *sync.WaitGroup)

func (*NodeServiceImpl) RunNodeStatusLoop

func (n *NodeServiceImpl) RunNodeStatusLoop(interval time.Duration, ctx context.Context, wg *sync.WaitGroup)

func (*NodeServiceImpl) StartStopComponents

func (*NodeServiceImpl) StatusChanged

func (n *NodeServiceImpl) StatusChanged(input v1.StatusChangedInput) (v1.StatusChangedOutput, error)

func (NodeServiceImpl) TerminateNode

func (*NodeServiceImpl) TryPlaceComponent

func (n *NodeServiceImpl) TryPlaceComponent(componentName string)

type NodeStatusByEmptyThenLoadAvg

type NodeStatusByEmptyThenLoadAvg []v1.NodeStatus

func (NodeStatusByEmptyThenLoadAvg) Len

func (NodeStatusByEmptyThenLoadAvg) Less

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

func (NodeStatusByEmptyThenLoadAvg) Swap

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

type NodeStatusByStartedAt

type NodeStatusByStartedAt []v1.NodeStatus

func (NodeStatusByStartedAt) Len

func (s NodeStatusByStartedAt) Len() int

func (NodeStatusByStartedAt) Less

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

func (NodeStatusByStartedAt) Swap

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

type PlacementOption

type PlacementOption struct {
	TargetNode *v1.NodeStatus
	Input      *v1.StartStopComponentsInput
}

func BestStartComponentOption

func BestStartComponentOption(placementByNode map[string]*PlacementOption, componentName string,
	requiredMemoryMiB int64, maxInstPerNode int64, displaceOK bool) *PlacementOption

func BestStopComponentOption

func BestStopComponentOption(placementByNode map[string]*PlacementOption, componentName string) *PlacementOption

func CalcAutoscalePlacement

func CalcAutoscalePlacement(nodes []v1.NodeStatus, componentsByName map[string]v1.Component) []*PlacementOption

func (*PlacementOption) ContainerCountByComponent

func (p *PlacementOption) ContainerCountByComponent() (byComp map[string]int, total int)

func (*PlacementOption) RamUsed

func (p *PlacementOption) RamUsed() int64

type PlacementOptionByCostDesc

type PlacementOptionByCostDesc struct {
	Options       []*PlacementOption
	ComponentName string
}

func (PlacementOptionByCostDesc) Len

func (PlacementOptionByCostDesc) Less

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

func (PlacementOptionByCostDesc) Swap

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

type PlacementOptionByNode

type PlacementOptionByNode []*PlacementOption

func (PlacementOptionByNode) Len

func (s PlacementOptionByNode) Len() int

func (PlacementOptionByNode) Less

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

func (PlacementOptionByNode) Swap

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

type ProjectDiff

type ProjectDiff struct {
	ComponentPut      []v1.Component
	ComponentRemove   []string
	EventSourcePut    []v1.EventSource
	EventSourceRemove []string
}

func DiffProject

func DiffProject(oldProject v1.Project, newProject v1.Project) ProjectDiff

type PullState

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

func NewPullState

func NewPullState(dockerClient *docker.Client) *PullState

func (*PullState) Pull

func (p *PullState) Pull(c v1.Component, forcePull bool)

type ShutdownFunc

type ShutdownFunc func()

Jump to

Keyboard shortcuts

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