arc

package
v0.0.0-...-116ca14 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAXIMUM_JOB_TIMEOUT = 86400
)

Variables

This section is empty.

Functions

func ExecuteAction

func ExecuteAction(ctx context.Context, job *Job)

func FactsFromContext

func FactsFromContext(ctx context.Context) (map[string]interface{}, bool)

func NewJobContext

func NewJobContext(ctx context.Context, timeout time.Duration, store *fact.Store) (context.Context, func())

func RegisterAgent

func RegisterAgent(name string, agent Agent)

func TempFile

func TempFile(dir, prefix string, suffix string) (f *os.File, err error)

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 ValidateReply(reply *Reply) error

func ValidateRequest

func ValidateRequest(request *Request) error

Types

type Agent

type Agent interface {
	Enabled() bool
	Enable(context.Context, *Job) (string, error)
	Disable(context.Context, *Job) (string, error)
}

type ChunkedReader

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

func NewChunkedReader

func NewChunkedReader(reader io.Reader, interval time.Duration, chunkSize int) *ChunkedReader

func (*ChunkedReader) Read

func (c *ChunkedReader) Read() (chunk []byte, err error)

type Job

type Job struct {
	Jid     string
	Payload string
	Agent   string
	Action  string
	// contains filtered or unexported fields
}

func NewJob

func NewJob(identity string, request *Request, out chan<- *Reply) *Job

func (*Job) Complete

func (j *Job) Complete(payload string)

func (*Job) Fail

func (j *Job) Fail(payload string)

func (*Job) Heartbeat

func (j *Job) Heartbeat(payload string)

func (*Job) Identity

func (j *Job) Identity() string

type JobState

type JobState byte
const (
	Queued JobState
	Executing
	Failed
	Complete
)

func (JobState) MarshalJSON

func (j JobState) MarshalJSON() ([]byte, error)

func (JobState) String

func (j JobState) String() string

func (*JobState) UnmarshalJSON

func (j *JobState) UnmarshalJSON(data []byte) error

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 CreateReply(request *Request, identity string, state JobState, payload string, number uint) *Reply

func ParseReply

func ParseReply(data *[]byte) (*Reply, error)

func (*Reply) ToJSON

func (r *Reply) ToJSON() ([]byte, error)

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 CreateRequest(agent string, action string, identity string, to string, timeout int, payload string) (*Request, error)

func ParseRequest

func ParseRequest(data *[]byte) (*Request, error)

func (*Request) ToJSON

func (r *Request) ToJSON() ([]byte, error)

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)

Jump to

Keyboard shortcuts

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