api

package
v0.0.0-...-3c36f29 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RPCListRuns  = "listRuns"
	RPCGetRuns   = "getRuns"
	RPCUpdateRun = "updateRun"
	RPCCreateRun = "createRun"
	RPCDeleteRun = "deleteRun"

	RPCListSteps         = "listSteps"
	RPCGetSteps          = "getSteps"
	RPCUpdateStepByUUID  = "updateStepByUUID"
	RPCUpdateStepByLabel = "updateStepByLabel"
	RPCDoStepByUUID      = "doStepByUUID"
	RPCDoStepByLabel     = "doStepByLabel"
)
View Source
const CurrentTimeStamp = "2006-01-02 15:04:05"

Variables

View Source
var ErrCannotDeleteRunIsInProgress = &ErrorCode{
	Code:    1012,
	Message: "a run cannot be deleted if in progress, unless force is specified",
}
View Source
var ErrCustomTemplateErrorThrown = &ErrorCode{
	Code:    1013,
	Message: "an intentional logical error was thrown by the specified template",
}
View Source
var ErrExternal = &ErrorCode{
	Code:    1003,
	Message: "failed to interact with an external resource",
}
View Source
var ErrInvalidParams = &ErrorCode{
	Code:    int(jsonrpc.ErrInvalidParams().Code),
	Message: jsonrpc.ErrInvalidParams().Message,
}
View Source
var ErrJobQueueUnavailable = &ErrorCode{
	Code:    1008,
	Message: "job queue may be full or unresponsive",
}
View Source
var ErrPrevStepStatusDoesNotMatch = &ErrorCode{
	Code:    1007,
	Message: "prev step status does not match an in transaction status",
}
View Source
var ErrRecordNotAffected = &ErrorCode{
	Code:    1002,
	Message: "failed to affect record",
}
View Source
var ErrRecordNotFound = &ErrorCode{
	Code:    1001,
	Message: "failed to locate record",
}
View Source
var ErrRunIsAlreadyDone = &ErrorCode{
	Code:    1005,
	Message: "run is already done, no change is possible",
}
View Source
var ErrShuttingDown = &ErrorCode{
	Code:    1006,
	Message: "shutting down server",
}
View Source
var ErrStatusNotChanged = &ErrorCode{
	Code:    1000,
	Message: "status did not change",
}
View Source
var ErrStepAlreadyInProgress = &ErrorCode{
	Code:    1004,
	Message: "step is already in progress",
}
View Source
var ErrStepDoneCannotBeChanged = &ErrorCode{
	Code:    1011,
	Message: "step is already done and we rely on it to not be changed",
}
View Source
var ErrStepNoRetriesLeft = &ErrorCode{
	Code:    1009,
	Message: "step status cannot be changed to in progress because no retries are left",
}
View Source
var ErrTemplateEvaluationFailed = &ErrorCode{
	Code:    1010,
	Message: "failed to evaluate a template expression",
}
View Source
var TestMode = false

Functions

func InitLogrus

func InitLogrus(out io.Writer, level log.Level)

func NewLocalizedError

func NewLocalizedError(msg string, args ...interface{}) error

Types

type AnyTime

type AnyTime time.Time

func (AnyTime) MarshalJSON

func (a AnyTime) MarshalJSON() ([]byte, error)

func (*AnyTime) Scan

func (a *AnyTime) Scan(src interface{}) error

func (*AnyTime) UnmarshalJSON

func (a *AnyTime) UnmarshalJSON(data []byte) error

type Context

type Context map[string]interface{}

func (*Context) Scan

func (c *Context) Scan(src interface{}) error

func (Context) Value

func (c Context) Value() (driver.Value, error)

type CreateRunParams

type CreateRunParams struct {
	Key          string           `json:"key,omitempty"`
	Template     TemplateContents `json:"template,omitempty"`
	TemplateType string           `json:"template-type,omitempty"`
	Options      Options          `json:"options,omitempty"`
}

type CreateRunsResult

type CreateRunsResult RunRecord

type DeleteQuery

type DeleteQuery struct {
	Ids     []uuid.UUID `json:"id,omitempty"`
	Force   bool        `json:"force,omitempty"`
	Options Options     `json:"options,omitempty"`
}

type DeleteRunsParams

type DeleteRunsParams DeleteQuery

type DeleteRunsResult

type DeleteRunsResult struct{}

type DoStepByLabelParams

type DoStepByLabelParams struct {
	RunId       uuid.UUID `json:"run-id,omitempty"`
	Label       string    `json:"label,omitempty"`
	Context     Context   `json:"context,omitempty"`
	StatusOwner string    `json:"status-owner,omitempty"`
	Options     Options   `json:"options,omitempty"`
}

type DoStepByLabelResult

type DoStepByLabelResult struct {
	UUID        uuid.UUID `json:"uuid,omitempty"`
	StatusOwner string    `json:"status-owner,omitempty"`
}

type DoStepByUUIDParams

type DoStepByUUIDParams struct {
	UUID        uuid.UUID `json:"uuid,omitempty"`
	Context     Context   `json:"context,omitempty"`
	StatusOwner string    `json:"status-owner,omitempty"`
	Options     Options   `json:"options,omitempty"`
}

type DoStepByUUIDResult

type DoStepByUUIDResult struct {
	StatusOwner string `json:"status-owner,omitempty"`
}

type Error

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

func NewError

func NewError(code *ErrorCode, msg string, args ...interface{}) *Error

func NewErrorWithData

func NewErrorWithData(code *ErrorCode, data interface{}, msg string, args ...interface{}) *Error

func NewErrorWithInput

func NewErrorWithInput(code *ErrorCode, input Input, msg string, args ...interface{}) *Error

func NewWrapError

func NewWrapError(code *ErrorCode, wrapErr error, msg string, args ...interface{}) *Error

func NewWrapErrorInternal

func NewWrapErrorInternal(code *ErrorCode, wrapErr error, data interface{}, input Input, msg string, args ...interface{}) *Error

func NewWrapErrorWithInput

func NewWrapErrorWithInput(code *ErrorCode, wrapErr error, input Input, msg string, args ...interface{}) *Error

func ResolveErrorAndLog

func ResolveErrorAndLog(err error, propagate bool) *Error

func (*Error) Caller

func (e *Error) Caller() *ErrorCaller

func (*Error) Code

func (e *Error) Code() *ErrorCode

func (*Error) Data

func (e *Error) Data() interface{}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Input

func (e *Error) Input() Input

func (*Error) Stack

func (e *Error) Stack() []byte

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorCaller

type ErrorCaller struct {
	File string
	Line int
}

type ErrorCode

type ErrorCode struct {
	Code    int
	Message string
}

type Expression

type Expression struct {
	AttributeName string `json:"attribute-name"`
	Operator      string // =,>=,>,<=,<,starts-with,ends-with,contains
	Value         interface{}
}

type GetRunsParams

type GetRunsParams GetRunsQuery

type GetRunsQuery

type GetRunsQuery struct {
	Ids              []uuid.UUID `json:"ids,omitempty"`
	ReturnAttributes []string    `json:"return-attributes,omitempty"`
	Options          Options     `json:"options,omitempty"`
}

type GetRunsResult

type GetRunsResult []RunRecord

type GetStepsParams

type GetStepsParams GetStepsQuery

type GetStepsQuery

type GetStepsQuery struct {
	UUIDs            []uuid.UUID `json:"uuids,omitempty"`
	ReturnAttributes []string    `json:"return-attributes,omitempty"`
	Options          Options     `json:"options,omitempty"`
}

type GetStepsResult

type GetStepsResult []StepRecord

type Input

type Input map[string]interface{}

type ListParams

type ListParams ListQuery

type ListQuery

type ListQuery struct {
	Range            RangeQuery   `json:"range,omitempty"`
	Sort             Sort         `json:"sort,omitempty"`
	Filters          []Expression `json:"filters,omitempty"`
	ReturnAttributes []string     `json:"return-attributes,omitempty"`
	Options          Options      `json:"options,omitempty"`
}

type ListRunsResult

type ListRunsResult struct {
	Range RangeResult `json:"range,omitempty"`
	Data  []RunRecord `json:"data,omitempty"`
}

type ListStepsResult

type ListStepsResult struct {
	Range RangeResult  `json:"range,omitempty"`
	Data  []StepRecord `json:"data,omitempty"`
}

type Options

type Options struct {
	GroupId uuid.UUID `json:"group-id,omitempty" validate:"required"`
}

type Parameters

type Parameters map[string]interface{}

type Range

type Range struct {
	Start int64
	End   int64
}

type RangeQuery

type RangeQuery struct {
	Range
	ReturnTotal bool `json:"return-total"`
}

type RangeResult

type RangeResult struct {
	Range
	Total int64 `json:"total,omitempty"`
}

type RunRecord

type RunRecord struct {
	GroupId         uuid.UUID      `db:"group_id" json:"group-id,omitempty"`
	Id              uuid.UUID      `json:"id,omitempty"`
	Key             string         `json:"key,omitempty"`
	Tags            pq.StringArray `db:"tags" json:"tags,omitempty"`
	CreatedAt       AnyTime        `db:"created_at" json:"created-at,omitempty"`
	CompleteBy      *AnyTime       `db:"complete_by" json:"complete-by,omitempty"`
	Now             AnyTime        `db:"now" json:"now,omitempty"`
	TemplateVersion int            `db:"template_version" json:"template-version,omitempty"`
	TemplateTitle   string         `db:"template_title" json:"template-title,omitempty"`
	Status          RunStatusType  `json:"status,omitempty"`
	Template        string         `json:"template,omitempty"`
}

func (*RunRecord) PrettyJSONTemplate

func (r *RunRecord) PrettyJSONTemplate() string

func (*RunRecord) PrettyYamlTemplate

func (r *RunRecord) PrettyYamlTemplate() string

type RunStatusType

type RunStatusType int
const (
	RunIdle       RunStatusType = 100
	RunInProgress RunStatusType = 200
	RunDone       RunStatusType = 300
)

func TranslateToRunStatus

func TranslateToRunStatus(status string) (RunStatusType, error)

func (RunStatusType) MarshalJSON

func (r RunStatusType) MarshalJSON() ([]byte, error)

func (RunStatusType) MarshalYAML

func (r RunStatusType) MarshalYAML() (interface{}, error)

func (RunStatusType) TranslateRunStatus

func (r RunStatusType) TranslateRunStatus() string

func (*RunStatusType) UnmarshalJSON

func (r *RunStatusType) UnmarshalJSON(data []byte) error

func (*RunStatusType) UnmarshalYAML

func (r *RunStatusType) UnmarshalYAML(unmarshal func(interface{}) error) error

type Sort

type Sort struct {
	Fields []string // ordered left to right
	Order  string   // Either asc/desc
}

type State

type State struct {
	Result interface{} `json:"result,omitempty" mapstructure:"result" yaml:"result"`
	Error  string      `json:"error,omitempty" mapstructure:"error" yaml:"error,omitempty"`
}

func (*State) Scan

func (s *State) Scan(src interface{}) error

func (State) Value

func (s State) Value() (driver.Value, error)

type StepRecord

type StepRecord struct {
	GroupId     uuid.UUID      `db:"group_id" json:"group-id,omitempty"`
	CreatedAt   AnyTime        `db:"created_at" json:"created-at,omitempty"`
	RunId       uuid.UUID      `db:"run_id" json:"run-id,omitempty"`
	Index       int            `db:"index" json:"index,omitempty"`
	Tags        pq.StringArray `db:"tags" json:"tags,omitempty"`
	Label       string         `json:"label,omitempty"`
	UUID        uuid.UUID      `json:"uuid,omitempty"`
	Name        string         `json:"name,omitempty"`
	Status      StepStatusType `json:"status,omitempty"`
	StatusOwner string         `db:"status_owner" json:"status-owner,omitempty"`
	Now         AnyTime        `db:"now" json:"now,omitempty"`
	Heartbeat   AnyTime        `json:"heartbeat,omitempty"`
	CompleteBy  *AnyTime       `db:"complete_by" json:"complete-by,omitempty"`
	Context     Context        `db:"context" json:"context,omitempty"`
	RetriesLeft int            `db:"retries_left" json:"retries-left,omitempty"`
	State       State          `json:"state,omitempty"`
}

func (*StepRecord) PrettyJSONState

func (s *StepRecord) PrettyJSONState() string

func (*StepRecord) PrettyYamlState

func (s *StepRecord) PrettyYamlState() string

type StepStatusType

type StepStatusType int
const (
	StepIdle       StepStatusType = 10
	StepPending    StepStatusType = 20
	StepInProgress StepStatusType = 30
	StepFailed     StepStatusType = 40
	StepDone       StepStatusType = 50
)

func TranslateToStepStatus

func TranslateToStepStatus(status string) (StepStatusType, error)

func (StepStatusType) MarshalJSON

func (s StepStatusType) MarshalJSON() ([]byte, error)

func (StepStatusType) TranslateStepStatus

func (s StepStatusType) TranslateStepStatus() string

func (*StepStatusType) UnmarshalJSON

func (s *StepStatusType) UnmarshalJSON(data []byte) error

type TemplateContents

type TemplateContents string

func (*TemplateContents) UnmarshalJSON

func (t *TemplateContents) UnmarshalJSON(data []byte) error

type UpdateQueryById

type UpdateQueryById struct {
	Id      uuid.UUID              `json:"id,omitempty"`
	Force   bool                   `json:"force,omitempty"`
	Changes map[string]interface{} `json:"changes,omitempty"`
	Options Options                `json:"options,omitempty"`
}

type UpdateQueryByLabel

type UpdateQueryByLabel struct {
	RunId       uuid.UUID              `json:"run-id,omitempty"`
	StatusOwner string                 `json:"status-owner,omitempty"`
	Label       string                 `json:"label,omitempty"`
	Force       bool                   `json:"force,omitempty"`
	Changes     map[string]interface{} `json:"changes,omitempty"`
	Options     Options                `json:"options,omitempty"`
}

type UpdateQueryByUUID

type UpdateQueryByUUID struct {
	UUID        uuid.UUID              `json:"uuid,omitempty"`
	StatusOwner string                 `json:"status-owner,omitempty"`
	Force       bool                   `json:"force,omitempty"`
	Changes     map[string]interface{} `json:"changes,omitempty"`
	Options     Options                `json:"options,omitempty"`
}

type UpdateRunParams

type UpdateRunParams UpdateQueryById

type UpdateRunResult

type UpdateRunResult struct{}

type UpdateStepByLabelParams

type UpdateStepByLabelParams UpdateQueryByLabel

type UpdateStepByLabelResult

type UpdateStepByLabelResult struct{}

type UpdateStepByUUIDParams

type UpdateStepByUUIDParams UpdateQueryByUUID

type UpdateStepByUUIDResult

type UpdateStepByUUIDResult struct{}

Jump to

Keyboard shortcuts

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