api

package
v0.0.0-...-36fcf6a Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JobStatusCreated = "created"
	JobStatusQueued  = "queued"
	JobStatusDone    = "done"
)

Job status

View Source
const (
	QueueNameJobs       = "puppet-master-jobs"
	QueueNameJobResults = "puppet-master-job-results"
)

Job queue names

View Source
const (
	ContentTypeHeader = "Content-Type"
	ContentTypeJSON   = "application/json"
)

HTTP header constants

View Source
const (
	LogFieldJobID = "job_id"
)

Logger field names

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONTime

type JSONTime struct {
	time.Time
}

JSONTime handles parsing and formatting timestamps according the ISO8601 standard

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

MarshalJSON formats the timestamp as JSON

func (JSONTime) String

func (t JSONTime) String() string

String returns a string representation of the time.

type Job

type Job struct {
	UUID       string                 `json:"uuid"`
	Rev        string                 `json:"_rev,omitempty"`
	Code       string                 `json:"code"`
	Status     string                 `json:"status"`
	Vars       map[string]string      `json:"vars"`
	Modules    map[string]string      `json:"modules"`
	Error      string                 `json:"error"`
	Logs       []Log                  `json:"logs"`
	Results    map[string]interface{} `json:"results"`
	CreatedAt  JSONTime               `json:"created_at"`
	StartedAt  *JSONTime              `json:"started_at"`
	FinishedAt *JSONTime              `json:"finished_at"`
	Duration   int                    `json:"duration"`
}

A Job is executed by the executor and stored in the database and holds all information required to let the puppets dance in the browser

func NewJob

func NewJob() *Job

NewJob creates a new Job instance

func (*Job) Equal

func (j *Job) Equal(j2 *Job) bool

Equal returns true when both given Jobs are equal nolint: gocyclo

type JobResponse

type JobResponse struct {
	Data *Job `json:"data"`
}

JobResponse is the wrapper around a job when returned through API

type JobResult

type JobResult struct {
	UUID       string                 `json:"uuid"`
	Error      string                 `json:"error"`
	Logs       []Log                  `json:"logs"`
	Results    map[string]interface{} `json:"results"`
	StartedAt  *JSONTime              `json:"started_at"`
	FinishedAt *JSONTime              `json:"finished_at"`
	Duration   int                    `json:"duration"`
}

A JobResult is emitted after a worker did the job and synced to database

func NewJobResult

func NewJobResult() *JobResult

NewJobResult creates a new JobResult instance

func (*JobResult) Equal

func (j *JobResult) Equal(j2 *JobResult) bool

Equal returns true when both given JobResults are equal

type JobsResponse

type JobsResponse struct {
	Data []*Job `json:"data"`
}

JobsResponse is the wrapper around a list of jobs when returned through API

type Log

type Log struct {
	Time    JSONTime `json:"time"`
	Level   string   `json:"level"`
	Message string   `json:"message"`
}

A Log represents a log line

Jump to

Keyboard shortcuts

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