Documentation ¶
Index ¶
- Constants
- type Agent
- func (a *Agent) HasConflict(potentialJobName string, potentialConflicts []string) (bool, string)
- func (a *Agent) Heartbeat(stop chan bool)
- func (a *Agent) Initialize() uint64
- func (a *Agent) JobScheduledElsewhere(jobName string)
- func (a *Agent) JobScheduledLocally(jobName string)
- func (a *Agent) JobUnscheduled(jobName string)
- func (a *Agent) MarshalJSON() ([]byte, error)
- func (a *Agent) MaybeBid(jo job.JobOffer)
- func (a *Agent) Purge()
- func (a *Agent) ReportUnitState(jobName string, us *unit.UnitState)
- func (a *Agent) StartJob(jobName string)
- func (a *Agent) StopJob(jobName string)
- type AgentState
- func (as *AgentState) GetJobsByPeer(peerName string) []string
- func (as *AgentState) GetOffersWithoutBids() []job.JobOffer
- func (as *AgentState) HasBid(name string) bool
- func (as *AgentState) LaunchedJobs() []string
- func (as *AgentState) Lock()
- func (as *AgentState) MarshalJSON() ([]byte, error)
- func (as *AgentState) PurgeJob(jobName string)
- func (as *AgentState) PurgeOffer(name string)
- func (as *AgentState) ScheduledHere(jobName string) bool
- func (as *AgentState) ScheduledJobs() []string
- func (as *AgentState) SetTargetState(jobName string, state job.JobState)
- func (as *AgentState) TrackBid(name string)
- func (as *AgentState) TrackJob(j *job.Job)
- func (as *AgentState) TrackOffer(offer job.JobOffer)
- func (as *AgentState) Unlock()
- type EventHandler
- func (eh *EventHandler) HandleCommandStartJob(ev event.Event)
- func (eh *EventHandler) HandleCommandStopJob(ev event.Event)
- func (eh *EventHandler) HandleEventJobDestroyed(ev event.Event)
- func (eh *EventHandler) HandleEventJobOffered(ev event.Event)
- func (eh *EventHandler) HandleEventJobScheduled(ev event.Event)
- func (eh *EventHandler) HandleEventJobUnscheduled(ev event.Event)
- func (eh *EventHandler) HandleEventUnitStateUpdated(ev event.Event)
Constants ¶
const (
// TTL to use with all state pushed to Registry
DefaultTTL = "30s"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
The Agent owns all of the coordination between the Registry, the local Machine, and the local UnitManager.
func (*Agent) HasConflict ¶ added in v0.3.0
HasConflict determines whether there are any known conflicts with the given argument
func (*Agent) Heartbeat ¶
Heartbeat updates the Registry periodically with this Agent's presence information as well as an acknowledgement of the jobs it is expected to be running.
func (*Agent) Initialize ¶ added in v0.2.0
Initialize prepares the Agent for normal operation by doing three things: 1. Announce presence to the Registry, tracking the etcd index of the operation 2. Discover any jobs that are scheduled locally, loading/starting them if they can run locally 3. Cache all unresolved job offers and bid for any that can be run locally The returned value is the etcd index at which the agent's presence was announced.
func (*Agent) JobScheduledElsewhere ¶ added in v0.4.0
JobScheduledElsewhere clears all state related to the indicated job before bidding for all oustanding jobs that can be run locally.
func (*Agent) JobScheduledLocally ¶ added in v0.4.0
JobScheduledLocally clears all state related to the indicated job's offers/bids before attempting to load and possibly start the job. The ability to run the job will be revalidated before loading, and unscheduled if such validation fails.
func (*Agent) JobUnscheduled ¶ added in v0.4.0
JobUnscheduled attempts to unload the indicated job only if it were scheduled here in the first place, otherwise the event is ignored. If unloading is necessary, all jobs that can be run locally will also be bid upon.
func (*Agent) MarshalJSON ¶ added in v0.2.0
func (*Agent) MaybeBid ¶ added in v0.4.0
MaybeBid bids for the given JobOffer only if the Agent determines that it is able to run the JobOffer's Job
func (*Agent) ReportUnitState ¶ added in v0.3.0
ReportUnitState attaches the current state of the Agent's Machine to the given unit.UnitState object, then persists that state in the Registry
type AgentState ¶
type AgentState struct { // index of local payload conflicts to the job they belong to Conflicts map[string][]string // contains filtered or unexported fields }
func NewState ¶
func NewState() *AgentState
func (*AgentState) GetJobsByPeer ¶
func (as *AgentState) GetJobsByPeer(peerName string) []string
Retrieve all Jobs that share a given Peer
func (*AgentState) GetOffersWithoutBids ¶ added in v0.1.1
func (as *AgentState) GetOffersWithoutBids() []job.JobOffer
GetOffersWithoutBids returns all tracked JobOffers that have no corresponding JobBid tracked in the same AgentState object.
func (*AgentState) HasBid ¶
func (as *AgentState) HasBid(name string) bool
func (*AgentState) LaunchedJobs ¶ added in v0.3.0
func (as *AgentState) LaunchedJobs() []string
func (*AgentState) Lock ¶
func (as *AgentState) Lock()
func (*AgentState) MarshalJSON ¶ added in v0.2.0
func (as *AgentState) MarshalJSON() ([]byte, error)
func (*AgentState) PurgeJob ¶ added in v0.3.0
func (as *AgentState) PurgeJob(jobName string)
PurgeJob removes all state tracked on behalf of a given job
func (*AgentState) PurgeOffer ¶ added in v0.3.0
func (as *AgentState) PurgeOffer(name string)
func (*AgentState) ScheduledHere ¶ added in v0.3.0
func (as *AgentState) ScheduledHere(jobName string) bool
func (*AgentState) ScheduledJobs ¶ added in v0.3.0
func (as *AgentState) ScheduledJobs() []string
func (*AgentState) SetTargetState ¶ added in v0.3.0
func (as *AgentState) SetTargetState(jobName string, state job.JobState)
func (*AgentState) TrackBid ¶
func (as *AgentState) TrackBid(name string)
func (*AgentState) TrackJob ¶ added in v0.3.0
func (as *AgentState) TrackJob(j *job.Job)
TrackJob extracts and stores information about the given job for later reference
func (*AgentState) TrackOffer ¶
func (as *AgentState) TrackOffer(offer job.JobOffer)
func (*AgentState) Unlock ¶
func (as *AgentState) Unlock()
type EventHandler ¶
type EventHandler struct {
// contains filtered or unexported fields
}
func NewEventHandler ¶
func NewEventHandler(agent *Agent) *EventHandler
func (*EventHandler) HandleCommandStartJob ¶ added in v0.3.0
func (eh *EventHandler) HandleCommandStartJob(ev event.Event)
func (*EventHandler) HandleCommandStopJob ¶ added in v0.3.0
func (eh *EventHandler) HandleCommandStopJob(ev event.Event)
func (*EventHandler) HandleEventJobDestroyed ¶ added in v0.3.0
func (eh *EventHandler) HandleEventJobDestroyed(ev event.Event)
func (*EventHandler) HandleEventJobOffered ¶
func (eh *EventHandler) HandleEventJobOffered(ev event.Event)
func (*EventHandler) HandleEventJobScheduled ¶
func (eh *EventHandler) HandleEventJobScheduled(ev event.Event)
func (*EventHandler) HandleEventJobUnscheduled ¶ added in v0.3.0
func (eh *EventHandler) HandleEventJobUnscheduled(ev event.Event)
func (*EventHandler) HandleEventUnitStateUpdated ¶ added in v0.3.0
func (eh *EventHandler) HandleEventUnitStateUpdated(ev event.Event)