Documentation ¶
Index ¶
- Constants
- func ExecuteAction(ctx context.Context, job *Job)
- func FactsFromContext(ctx context.Context) (map[string]interface{}, bool)
- func NewJobContext(ctx context.Context, timeout time.Duration, store *fact.Store) (context.Context, func())
- func RegisterAgent(name string, agent Agent)
- func TempFile(dir, prefix string, suffix string) (f *os.File, err error)
- func ValidateRegistration(reg *Registration) error
- func ValidateReply(reply *Reply) error
- func ValidateRequest(request *Request) error
- type Agent
- type ChunkedReader
- type Job
- type JobState
- type Registration
- type Registry
- type Reply
- type Request
- type Subprocess
Constants ¶
View Source
const (
MAXIMUM_JOB_TIMEOUT = 86400
)
Variables ¶
This section is empty.
Functions ¶
func ExecuteAction ¶
func NewJobContext ¶
func RegisterAgent ¶
func TempFile ¶
TempFile creates a new temporary file in the directory dir with a name beginning with prefix, opens the file for reading and writing, and returns the resulting *os.File. If dir is the empty string, TempFile uses the default directory for temporary files (see os.TempDir). Multiple programs calling TempFile simultaneously will not choose the same file. The caller can use f.Name() to find the pathname of the file. It is the caller's responsibility to remove the file when no longer needed.
func ValidateRegistration ¶
func ValidateRegistration(reg *Registration) error
func ValidateReply ¶
func ValidateRequest ¶
Types ¶
type ChunkedReader ¶
type ChunkedReader struct {
// contains filtered or unexported fields
}
func NewChunkedReader ¶
func (*ChunkedReader) Read ¶
func (c *ChunkedReader) Read() (chunk []byte, err error)
type Job ¶
type JobState ¶
type JobState byte
const ( Queued JobState Executing Failed Complete )
func (JobState) MarshalJSON ¶
func (*JobState) UnmarshalJSON ¶
type Registration ¶
type Registration struct { RegistrationID string `json:"registration_id"` Version int `json:"version"` Sender string `json:"sender"` Organization string `json:"organization"` Project string `json:"project"` Payload string `json:"payload"` }
func CreateRegistration ¶
func CreateRegistration(organization, project, identity, payload string) (*Registration, error)
func ParseRegistration ¶
func ParseRegistration(data *[]byte) (*Registration, error)
func (*Registration) ToJSON ¶
func (r *Registration) ToJSON() ([]byte, error)
type Registry ¶
type Registry interface { HasAction(agent string, action string) bool Agents() []string Actions(agent string) []string IsEnabled(agent string) bool }
func AgentRegistry ¶
func AgentRegistry() Registry
type Reply ¶
type Reply struct { Version int `json:"version"` Sender string `json:"sender"` RequestID string `json:"request_id"` Agent string `json:"agent"` Action string `json:"action"` State JobState `json:"state"` Final bool `json:"final"` Payload string `json:"payload"` Number uint `json:"number"` }
func CreateReply ¶
func ParseReply ¶
type Request ¶
type Request struct { Version int `json:"version"` Sender string `json:"sender"` RequestID string `json:"request_id"` To string `json:"to"` Timeout int `json:"timeout"` Agent string `json:"agent"` Action string `json:"action"` Payload string `json:"payload"` }
func CreateRequest ¶
func ParseRequest ¶
type Subprocess ¶
type Subprocess struct { Command []string Dir string Env []string // contains filtered or unexported fields }
func NewSubprocess ¶
func NewSubprocess(command string, args ...string) *Subprocess
func (*Subprocess) Done ¶
func (s *Subprocess) Done() <-chan struct{}
func (*Subprocess) Error ¶
func (s *Subprocess) Error() error
func (*Subprocess) Exited ¶
func (s *Subprocess) Exited() bool
func (*Subprocess) Kill ¶
func (s *Subprocess) Kill()
func (*Subprocess) ProcessState ¶
func (s *Subprocess) ProcessState() *os.ProcessState
func (*Subprocess) Start ¶
func (s *Subprocess) Start() (<-chan string, error)
Click to show internal directories.
Click to hide internal directories.