bl

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: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDoRestTimeout          = 60
	DefaultMaxResponseHeaderBytes = 64 * 1024
	DefaultMaxResponseBodyBytes   = 256 * 1024
)
View Source
const (
	OnPhasePreTransaction = iota
	OnPhaseInTransaction
	OnPhasePostTransaction
)
View Source
const CodeDatabaseVersion = 1
View Source
const (
	ExpirationStepIndex = -1
)
View Source
const RecoveryChannelName = "recovery"

Variables

View Source
var DefaultAllowedBuiltins = []*ast.Builtin{}/* 141 elements not displayed */
View Source
var LabelFormat = regexp.MustCompile(`^[a-zA-Z][a-zA-Z_0-9]*`)
View Source
var TESTSLock sync.Mutex

Functions

func GetRunByIdTx

func GetRunByIdTx(tx *sqlx.Tx, options api.Options, id uuid.UUID) (*api.RunRecord, error)

func InitLogrus

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

Types

type BL

type BL struct {
	TLSEnable                       bool
	TLSEnableClientCertificateCheck bool
	TLSCertFile                     string
	TLSKeyFile                      string
	TLSCAFile                       string
	InterruptServe                  chan os.Signal
	ServerReady                     bool

	ValveCtx       context.Context
	ShutdownValve  *valve.Valve
	CancelValveCtx context.CancelFunc

	JobQueueType JOBQueueType

	PendingRecursionDepthLimit int

	InstanceId string

	DAO    *dao.DAO
	Client *client.CLI
	// contains filtered or unexported fields
}

func New

func New(daoParameters *dao.ParametersType) (*BL, error)

func (*BL) DeleteRuns

func (b *BL) DeleteRuns(query *api.DeleteQuery) error

func (*BL) DoStepByLabel

func (b *BL) DoStepByLabel(params *api.DoStepByLabelParams, synchronous bool) (api.DoStepByLabelResult, error)

func (*BL) DoStepByUUID

func (b *BL) DoStepByUUID(params *api.DoStepByUUIDParams, synchronous bool) (api.DoStepByUUIDResult, error)

func (*BL) Enqueue

func (b *BL) Enqueue(do *doWork) error

func (*BL) GetRun

func (b *BL) GetRun(options api.Options, id uuid.UUID) (*api.RunRecord, error)

func (*BL) GetRuns

func (b *BL) GetRuns(query *api.GetRunsQuery) ([]api.RunRecord, error)

func (*BL) GetSteps

func (b *BL) GetSteps(query *api.GetStepsQuery) ([]api.StepRecord, error)

func (*BL) IsPostgreSQL

func (b *BL) IsPostgreSQL() bool

func (*BL) IsSqlite

func (b *BL) IsSqlite() bool

func (*BL) ListRuns

func (b *BL) ListRuns(query *api.ListQuery) ([]api.RunRecord, *api.RangeResult, error)

func (*BL) ListSteps

func (b *BL) ListSteps(query *api.ListQuery) ([]api.StepRecord, *api.RangeResult, error)

func (*BL) MigrateDB

func (b *BL) MigrateDB(autoMigrate bool) error

func (*BL) QueuesIdle

func (b *BL) QueuesIdle() bool

try not to use this, this is primarily for testing

func (*BL) UpdateRunStatus

func (b *BL) UpdateRunStatus(options api.Options, runId uuid.UUID, newStatus api.RunStatusType) error

func (*BL) UpdateStepByLabel

func (b *BL) UpdateStepByLabel(query *api.UpdateQueryByLabel) error

func (*BL) UpdateStepByUUID

func (b *BL) UpdateStepByUUID(query *api.UpdateQueryByUUID) error

type DO

type DO interface {
	Describe() string
}

type Decision

type Decision struct {
	Name   string `json:"name,omitempty"`
	Label  string `json:"label,omitempty"`
	Result string `json:"result,omitempty"`
}

type DoType

type DoType string
const (
	DoTypeREST     DoType = "REST"
	DoTypeEVALUATE DoType = "EVALUATE"
)

type DoubleCurlyToken

type DoubleCurlyToken struct {
	Start int
	End   int
}

func TokenizeCurlyPercent

func TokenizeCurlyPercent(originalString string) (result []DoubleCurlyToken, sanitizedString string)

type Event

type Event struct {
	Decisions []RulesDecision `json:"decisions,omitempty"`
	Rules     []Rule          `json:"rules,omitempty"`
}

type Expiration

type Expiration struct {
	CompleteBy int64           `json:"complete-by,omitempty" mapstructure:"complete-by" yaml:"complete-by,omitempty"`
	Decisions  []RulesDecision `json:"decisions,omitempty"`
	Rules      []Rule          `json:"rules,omitempty"`
}

type JOBQueueType

type JOBQueueType int
const (
	JobQueueTypeMemoryQueue JOBQueueType = 0
	JobQueueTypeRabbitMQ    JOBQueueType = 10
)

func TranslateToJOBQueueType

func TranslateToJOBQueueType(status string) (JOBQueueType, error)

type On

type On struct {
	InProgress Event `json:"in-progress,omitempty" mapstructure:"in-progress" yaml:"in-progress,omitempty"`
	Pending    Event `json:"pending,omitempty" mapstructure:"pending" yaml:"pending,omitempty"`
	Done       Event `json:"done,omitempty" mapstructure:"done" yaml:"done,omitempty"`
	Failed     Event `json:"failed,omitempty" mapstructure:"failed" yaml:"failed,omitempty"`
}

type RabbitMQ

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

func (*RabbitMQ) Close

func (r *RabbitMQ) Close()

func (*RabbitMQ) LeaveConsumer

func (r *RabbitMQ) LeaveConsumer(startExit *bool, done *chan struct{}, wg *sync.WaitGroup)

type RecoveryMessage

type RecoveryMessage struct {
	InstanceUUID string `json:"instance-uuid"`
	ReachedLimit bool
}

type Rego

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

type Rule

type Rule struct {
	If   string `json:"if,omitempty"`
	Then *Then  `json:"then,omitempty"`
}

type RulesDecision

type RulesDecision struct {
	Label string `json:"label"`
	Input string `json:"input,omitempty"`
}

type Step

type Step struct {
	Name        string         `json:"name,omitempty"`
	Tags        pq.StringArray `json:"tags,omitempty"`
	Label       string         `json:"label,omitempty"`
	Description string         `json:"description,omitempty"`
	Parameters  api.Parameters `json:"parameters,omitempty"`
	Do          interface{}    `json:"do,omitempty"`
	On          On             `json:"on,omitempty"`
	Retries     int            `json:"retries,omitempty"`
	// contains filtered or unexported fields
}

func (*Step) AdjustUnmarshalStep

func (s *Step) AdjustUnmarshalStep(t *Template, index int) error

func (*Step) GetCompleteBy

func (s *Step) GetCompleteBy(BL *BL) *int64

func (*Step) GetHeartBeatTimeout

func (s *Step) GetHeartBeatTimeout() time.Duration

type StepDo

type StepDo struct {
	Type             DoType `json:"type,omitempty" mapstructure:"type" yaml:"type,omitempty"`
	HeartBeatTimeout int64  `json:"heartbeat-timeout,omitempty" mapstructure:"heartbeat-timeout" yaml:"heartbeat-timeout,omitempty"`
	Retries          int64  `json:"retries,omitempty" mapstructure:"retries" yaml:"retries,omitempty"`
	CompleteBy       int64  `json:"complete-by,omitempty" mapstructure:"complete-by" yaml:"complete-by,omitempty"`
}

type StepDoEvaluate

type StepDoEvaluate struct {
	StepDo  `yaml:",inline" mapstructure:",squash"`
	Options StepDoEvaluateOptions `json:"options,omitempty"`
}

type StepDoEvaluateOptions

type StepDoEvaluateOptions struct {
	Result string `json:"result,omitempty"`
}

type StepDoREST

type StepDoREST struct {
	StepDo  `yaml:",inline" mapstructure:",squash"`
	Options StepDoRESTOptions `json:"options,omitempty"`
}

func (StepDoREST) Describe

func (do StepDoREST) Describe() string

type StepDoRESTOptions

type StepDoRESTOptions struct {
	Timeout              int64       `json:"timeout,omitempty"`
	Method               string      `json:"method,omitempty"`
	Url                  string      `json:"url,omitempty"`
	Headers              http.Header `json:"headers,omitempty"`
	MaxResponseBodyBytes int64       `json:"max-response-body-bytes,omitempty" mapstructure:"max-response-body-bytes" yaml:"max-response-body-bytes,omitempty"`
	Body                 string      `json:"body,omitempty"`
}

type StepStateRest

type StepStateRest struct {
	Body         interface{}         `json:"body,omitempty" mapstructure:"body" yaml:"body,omitempty"`
	ContentType  string              `json:"content-type,omitempty" mapstructure:"content-type" yaml:"content-type,omitempty"`
	StatusCode   int                 `json:"status-code,omitempty" mapstructure:"status-code" yaml:"status-code,omitempty"`
	StatusPhrase string              `json:"status-phrase,omitempty" mapstructure:"status-phrase" yaml:"status-phrase,omitempty"`
	Header       map[string][]string `json:"header,omitempty" mapstructure:"header" yaml:"header,omitempty"`
}

type Template

type Template struct {
	Title      string         `json:"title,omitempty"`
	Version    int            `json:"version,omitempty"`
	Expiration Expiration     `json:"expiration,omitempty"`
	Steps      []Step         `json:"steps,omitempty"`
	Tags       pq.StringArray `json:"tags,omitempty"`
	Decisions  []Decision     `json:"decisions,omitempty"`
	Parameters api.Parameters `json:"parameters,omitempty"`
	// contains filtered or unexported fields
}

func (*Template) CreateRun

func (t *Template) CreateRun(BL *BL, options api.Options, key string) (*api.RunRecord, error)

func (*Template) EvaluateCurlyPercent

func (t *Template) EvaluateCurlyPercent(BL *BL, step *Step, str string, currentContext api.Context, decisions api.Input, uncommitted *uncommittedResult) (string, error)

func (*Template) LoadAndCreateRun

func (t *Template) LoadAndCreateRun(BL *BL, options api.Options, key string, fileName string, fileType string) (uuid.UUID, error)

func (*Template) LoadFromBytes

func (t *Template) LoadFromBytes(BL *BL, runId uuid.UUID, isYaml bool, yamlDocument []byte) error

func (*Template) RefreshInput

func (t *Template) RefreshInput(BL *BL, options api.Options, runId uuid.UUID)

func (*Template) ResolveContext

func (t *Template) ResolveContext(BL *BL, step *Step, jsonStr string, currentContext api.Context, decisions api.Input, uncommitted *uncommittedResult) (api.Context, error)

func (*Template) ResolveInput

func (t *Template) ResolveInput(BL *BL, step *Step, jsonStr string, currentContext api.Context, uncommitted *uncommittedResult) (api.Input, error)

func (*Template) StartDo

func (t *Template) StartDo(BL *BL, options api.Options, runId uuid.UUID, label string, stepUUID uuid.UUID, newStatusOwner string, currentContext api.Context) (*api.StepRecord, error)

func (*Template) TransitionStateAndStatus

func (t *Template) TransitionStateAndStatus(BL *BL, options api.Options, runId uuid.UUID, label string, stepUUID uuid.UUID, prevStatus *api.StepStatusType, newStatus api.StepStatusType, newStatusOwner string, currentContext api.Context, newState *api.State, force bool) (*api.StepRecord, error)

type Then

type Then struct {
	SetRunStatus *api.RunStatusType `json:"set-run-status,omitempty" mapstructure:"set-run-status,omitempty" yaml:"set-run-status,omitempty"`
	Error        *ThenError         `json:"error,omitempty"`
	Do           []ThenDo           `json:"do,omitempty"`
}

type ThenDo

type ThenDo struct {
	Label   string `json:"label,omitempty"`
	Context string `json:"context,omitempty"`
}

type ThenError

type ThenError struct {
	Propagate *bool  `json:"propagate,omitempty"`
	Message   string `json:"message,omitempty"`
	Data      string `json:"data,omitempty"`
}

type WorkType

type WorkType bool
const (
	RunWorkType  WorkType = true
	StepWorkType WorkType = false
)

Jump to

Keyboard shortcuts

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