eventline

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: ISC Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinUsernameLength = 3
	MaxUsernameLength = 100

	MinPasswordLength = 8
	MaxPasswordLength = 100

	SaltSize = 32 // bytes

	// Current OWASP recommendations are 310'000+
	// (https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#pbkdf2).
	//
	// Note that changing it requires re-hashing all password hashes in the
	// database. Do not change it.
	NbPBKDF2Iterations = 350_000
)
View Source
const (
	MinNameLength = 1
	MaxNameLength = 100

	MinLabelLength = 1
	MaxLabelLength = 100

	MinDescriptionLength = 1
	MaxDescriptionLength = 500
)
View Source
const (
	DefaultCursorSize = 20
	MinCursorSize     = 1
	MaxCursorSize     = 100
)
View Source
const (
	MinPageSize = 1
	MaxPageSize = 100
)
View Source
const DefaultSort = "id"

Variables

View Source
var AccountRoleValues = []AccountRole{
	AccountRoleUser,
	AccountRoleAdmin,
}
View Source
var Connectors = map[string]Connector{}
View Source
var GlobalEncryptionKey cryptoutils.AES256Key
View Source
var (
	NameRE = regexp.MustCompile(`^[a-z0-9][a-z0-9\-_]*$`)
)
View Source
var RunnerDefs = map[string]*RunnerDef{}
View Source
var TemplateFuncMap = map[string]interface{}{
	"add": func(a, b int) int {
		return a + b
	},

	"sub": func(a, b int) int {
		return a - b
	},

	"toSentence": utils.ToSentence,

	"join": strings.Join,

	"stringMember": func(s string, ss []string) bool {
		for _, s2 := range ss {
			if s == s2 {
				return true
			}
		}

		return false
	},

	"quoteString": func(s string) string {
		return fmt.Sprintf("%q", s)
	},
}
View Source
var ZeroId = ksuid.Zero

Functions

func APIKeyNameExists

func APIKeyNameExists(conn pg.Conn, name string, scope Scope) (bool, error)

func CheckConnectorName

func CheckConnectorName(v *ejson.Validator, token string, cname string) bool

func CheckDescription

func CheckDescription(v *ejson.Validator, token string, label string)

func CheckEventName

func CheckEventName(v *ejson.Validator, token string, cname, name string) bool

func CheckEventRef

func CheckEventRef(v *ejson.Validator, token string, ref EventRef) bool

func CheckIdentityName

func CheckIdentityName(v *ejson.Validator, token string, cname, itype string)

func CheckLabel

func CheckLabel(v *ejson.Validator, token string, label string)

func CheckName

func CheckName(v *ejson.Validator, token interface{}, name string)

func ConnectorExists

func ConnectorExists(name string) (exists bool)

func CountStartedJobExecutions

func CountStartedJobExecutions(conn pg.Conn, scope Scope) (int64, error)

func DecryptAES256

func DecryptAES256(data []byte) ([]byte, error)

func DeleteAccount

func DeleteAccount(conn pg.Conn, accountId Id) error

func DeleteExpiredJobExecutions added in v1.0.0

func DeleteExpiredJobExecutions(conn pg.Conn) (int64, error)

func DeleteFavouriteJob

func DeleteFavouriteJob(conn pg.Conn, jobId Id, scope Scope) error

func DeleteJobs

func DeleteJobs(conn pg.Conn, scope Scope) error

func DeleteOldSessions added in v1.0.0

func DeleteOldSessions(conn pg.Conn, retention int) (int64, error)

func EncryptAES256

func EncryptAES256(data []byte) ([]byte, error)

func EventDefExists

func EventDefExists(ref EventRef) bool

func EventExists

func EventExists(cname, name string) bool

func GenerateSalt

func GenerateSalt() []byte

func HashAPIKey

func HashAPIKey(key string) []byte

func HashPassword

func HashPassword(password string, salt []byte) []byte

func IdentityExists

func IdentityExists(cname, itype string) bool

func IdentityNameExists

func IdentityNameExists(conn pg.Conn, name string, scope Scope) (bool, error)

func IsJobAbortedError

func IsJobAbortedError(err error) bool

func JSONFields

func JSONFields(value interface{}) (map[string]string, error)

func LoadJobNamesById

func LoadJobNamesById(conn pg.Conn, ids Ids) (map[Id]string, error)

func LoadJobStats

func LoadJobStats(conn pg.Conn, jobIds Ids, scope Scope) (map[Id]*JobStats, error)

func LoadLastJobExecutions

func LoadLastJobExecutions(conn pg.Conn, jobIds Ids, scope Scope) (map[Id]*JobExecution, error)

func ProjectNameExists

func ProjectNameExists(conn pg.Conn, name string) (bool, error)

func RenderTermData added in v1.0.0

func RenderTermData(rawData string) (string, error)

func ReversePageElements

func ReversePageElements(elts []PageElement)

func StartsWithShebang

func StartsWithShebang(data string) bool

func SubscriptionParametersEqual

func SubscriptionParametersEqual(sp1, sp2 SubscriptionParameters) bool

func UpdateAccountLastProjectId

func UpdateAccountLastProjectId(conn pg.Conn, accountId Id, projectId *Id) error

func UpdateAccountsForProjectDeletion

func UpdateAccountsForProjectDeletion(conn pg.Conn, projectId Id) error

func UpdateSessionsForProjectDeletion

func UpdateSessionsForProjectDeletion(conn pg.Conn, projectId Id) error

func UsernameExists

func UsernameExists(conn pg.Conn, username string) (bool, error)

func ValidateConnectorName

func ValidateConnectorName(name string) error

Types

type APIKey

type APIKey struct {
	Id           Id         `json:"id"`
	AccountId    Id         `json:"account_id"`
	Name         string     `json:"name"`
	CreationTime time.Time  `json:"creation_time"`
	LastUseTime  *time.Time `json:"last_use_time,omitempty"`
	KeyHash      []byte     `json:"-"`
}

func (*APIKey) Delete

func (k *APIKey) Delete(conn pg.Conn, scope Scope) error

func (*APIKey) FromRow

func (k *APIKey) FromRow(row pgx.Row) error

func (*APIKey) Insert

func (k *APIKey) Insert(conn pg.Conn) error

func (*APIKey) LoadForUpdate

func (k *APIKey) LoadForUpdate(conn pg.Conn, id Id, scope Scope) error

func (*APIKey) LoadUpdateByKeyHash

func (k *APIKey) LoadUpdateByKeyHash(conn pg.Conn, keyHash []byte) error

func (*APIKey) SortKey

func (k *APIKey) SortKey(sort string) (key string)

type APIKeys

type APIKeys []*APIKey

func (*APIKeys) AddFromRow

func (ks *APIKeys) AddFromRow(row pgx.Row) error

func (APIKeys) Page

func (ks APIKeys) Page(cursor *Cursor) *Page

type Account

type Account struct {
	Id            Id               `json:"id"`
	CreationTime  time.Time        `json:"creation_time"`
	Username      string           `json:"username"`
	Salt          []byte           `json:"-"`
	PasswordHash  []byte           `json:"-"`
	Role          AccountRole      `json:"role"`
	LastLoginTime *time.Time       `json:"last_login_time,omitempty"`
	LastProjectId *Id              `json:"last_project_id,omitempty"`
	Settings      *AccountSettings `json:"settings"`
}

func (*Account) CheckPassword

func (a *Account) CheckPassword(password string) bool

func (*Account) FromRow

func (a *Account) FromRow(row pgx.Row) error

func (*Account) Insert

func (a *Account) Insert(conn pg.Conn) error

func (*Account) Load

func (a *Account) Load(conn pg.Conn, id Id) error

func (*Account) LoadByUsernameForUpdate

func (a *Account) LoadByUsernameForUpdate(conn pg.Conn, username string) error

func (*Account) LoadForUpdate

func (a *Account) LoadForUpdate(conn pg.Conn, id Id) error

func (*Account) SelfUpdate

func (a *Account) SelfUpdate(conn pg.Conn) error

func (*Account) SortKey

func (a *Account) SortKey(sort string) (key string)

func (*Account) Update

func (a *Account) Update(conn pg.Conn) error

func (*Account) UpdateForLogin

func (a *Account) UpdateForLogin(conn pg.Conn) error

type AccountPasswordUpdate

type AccountPasswordUpdate struct {
	Password             string `json:"password"`
	PasswordConfirmation string `json:"password_confirmation"`
}

func (*AccountPasswordUpdate) ValidateJSON added in v1.1.0

func (au *AccountPasswordUpdate) ValidateJSON(v *ejson.Validator)

type AccountProjectScope

type AccountProjectScope struct {
	AccountId Id
	ProjectId Id
}

func (*AccountProjectScope) SQLCondition

func (scope *AccountProjectScope) SQLCondition() string

func (*AccountProjectScope) SQLCondition2

func (scope *AccountProjectScope) SQLCondition2(correlation string) string

type AccountRole

type AccountRole string
const (
	AccountRoleUser  AccountRole = "user"
	AccountRoleAdmin AccountRole = "admin"
)

type AccountScope

type AccountScope struct {
	AccountId Id
}

func (*AccountScope) SQLCondition

func (scope *AccountScope) SQLCondition() string

func (*AccountScope) SQLCondition2

func (scope *AccountScope) SQLCondition2(correlation string) string

type AccountSelfUpdate

type AccountSelfUpdate struct {
	Settings *AccountSettings `json:"settings"`
}

func (*AccountSelfUpdate) ValidateJSON added in v1.1.0

func (au *AccountSelfUpdate) ValidateJSON(v *ejson.Validator)

type AccountSettings

type AccountSettings struct {
	DateFormat DateFormat `json:"date_format,omitempty"`
	PageSize   int        `json:"page_size,omitempty"`
}

func DefaultAccountSettings

func DefaultAccountSettings() *AccountSettings

func (*AccountSettings) ValidateJSON added in v1.1.0

func (as *AccountSettings) ValidateJSON(v *ejson.Validator)

type AccountUpdate

type AccountUpdate struct {
	Username string      `json:"username"`
	Role     AccountRole `json:"role"`
}

func (*AccountUpdate) ValidateJSON added in v1.1.0

func (au *AccountUpdate) ValidateJSON(v *ejson.Validator)

type Accounts

type Accounts []*Account

func (*Accounts) AddFromRow

func (as *Accounts) AddFromRow(row pgx.Row) error

func (*Accounts) LoadAll

func (as *Accounts) LoadAll(conn pg.Conn) error

func (Accounts) Page

func (as Accounts) Page(cursor *Cursor) *Page

type CommandData

type CommandData struct {
	Parameters []*Parameter `json:"parameters,omitempty"`
	Pipelines  []string     `json:"pipelines"` //names
}

func (*CommandData) ValidateJSON added in v1.1.0

func (d *CommandData) ValidateJSON(v *ejson.Validator)

type Connector

type Connector interface {
	Name() string
	Definition() *ConnectorDef
	DefaultCfg() ConnectorCfg

	Init(ConnectorCfg, ConnectorInitData) error
	Terminate()
}

func FindConnector

func FindConnector(name string) (Connector, bool)

func GetConnector

func GetConnector(name string) Connector

type ConnectorCfg

type ConnectorCfg interface {
	ejson.Validatable
}

type ConnectorDef

type ConnectorDef struct {
	Name string

	Identities map[string]*IdentityDef
	Events     map[string]*EventDef

	Worker WorkerBehaviour
}

func GetConnectorDef

func GetConnectorDef(name string) *ConnectorDef

func NewConnectorDef

func NewConnectorDef(name string) *ConnectorDef

func (*ConnectorDef) AddEvent

func (c *ConnectorDef) AddEvent(edef *EventDef)

func (*ConnectorDef) AddIdentity

func (c *ConnectorDef) AddIdentity(idef *IdentityDef)

func (*ConnectorDef) Event

func (c *ConnectorDef) Event(typeName string) *EventDef

func (*ConnectorDef) EventExists

func (c *ConnectorDef) EventExists(typeName string) (exists bool)

func (*ConnectorDef) Identity

func (c *ConnectorDef) Identity(typeName string) *IdentityDef

func (*ConnectorDef) IdentityExists

func (c *ConnectorDef) IdentityExists(typeName string) (exists bool)

func (*ConnectorDef) ValidateEventName

func (c *ConnectorDef) ValidateEventName(name string) error

func (*ConnectorDef) ValidateIdentityType

func (c *ConnectorDef) ValidateIdentityType(typeName string) error

type ConnectorInitData

type ConnectorInitData struct {
	Pg               *pg.Client
	Log              *log.Logger
	WebHTTPServerURI *url.URL
}

type Cursor

type Cursor struct {
	Before string `json:"before,omitempty"`
	After  string `json:"after,omitempty"`
	Size   int    `json:"size,omitempty"`
	Sort   string `json:"sort,omitempty"`
	Order  Order  `json:"order,omitempty"`
}

func (*Cursor) ParseQuery

func (pc *Cursor) ParseQuery(query url.Values, sorts Sorts, accountSettings *AccountSettings) error

func (*Cursor) Query

func (c *Cursor) Query() url.Values

func (*Cursor) SQLConditionOrderLimit

func (c *Cursor) SQLConditionOrderLimit(sorts Sorts) string

func (*Cursor) SQLConditionOrderLimit2

func (c *Cursor) SQLConditionOrderLimit2(sorts Sorts, correlation string) string

func (*Cursor) URL

func (c *Cursor) URL() *url.URL

type DateFormat

type DateFormat string
const (
	DateFormatAbsolute DateFormat = "absolute"
	DateFormatRelative DateFormat = "relative"
)

type Event

type Event struct {
	Id              Id          `json:"id"`
	ProjectId       Id          `json:"project_id"`
	JobId           Id          `json:"job_id"`
	CreationTime    time.Time   `json:"creation_time"`
	EventTime       time.Time   `json:"event_time"`
	Connector       string      `json:"connector"`
	Name            string      `json:"name"`
	Data            EventData   `json:"data"`
	DataValue       interface{} `json:"-"`
	Processed       bool        `json:"processed,omitempty"`
	OriginalEventId *Id         `json:"original_event_id,omitempty"`
}

func LoadEventForProcessing

func LoadEventForProcessing(conn pg.Conn) (*Event, error)

func (*Event) Def

func (e *Event) Def() *EventDef

func (*Event) FromRow

func (e *Event) FromRow(row pgx.Row) error

func (*Event) Insert

func (e *Event) Insert(conn pg.Conn) error

func (*Event) Load

func (e *Event) Load(conn pg.Conn, id Id, scope Scope) error

func (*Event) SortKey

func (e *Event) SortKey(sort string) (key string)

func (*Event) Update

func (e *Event) Update(conn pg.Conn) error

type EventData

type EventData interface {
}

type EventDef

type EventDef struct {
	Name string

	Data                   EventData
	SubscriptionParameters SubscriptionParameters
}

func GetEventDef

func GetEventDef(ref EventRef) *EventDef

func NewEventDef

func NewEventDef(name string, data EventData, subscriptionParameters SubscriptionParameters) *EventDef

func (*EventDef) DecodeData

func (edef *EventDef) DecodeData(data []byte) (EventData, error)

func (*EventDef) DecodeSubscriptionParameters

func (edef *EventDef) DecodeSubscriptionParameters(data []byte) (SubscriptionParameters, error)

type EventRef

type EventRef struct {
	Connector string
	Event     string
}

func (EventRef) MarshalJSON

func (ref EventRef) MarshalJSON() ([]byte, error)

func (*EventRef) Parse

func (ref *EventRef) Parse(s string) error

func (EventRef) String

func (ref EventRef) String() string

func (*EventRef) UnmarshalJSON

func (ref *EventRef) UnmarshalJSON(data []byte) error

type Events

type Events []*Event

func (*Events) AddFromRow

func (is *Events) AddFromRow(row pgx.Row) error

func (Events) Page

func (es Events) Page(cursor *Cursor) *Page

type ExecutionContext

type ExecutionContext struct {
	Event      *Event                 `json:"event,omitempty"`
	Parameters map[string]interface{} `json:"parameters,omitempty"`
	Identities map[string]*Identity   `json:"identities,omitempty"`
}

func (*ExecutionContext) Encode

func (ctx *ExecutionContext) Encode() ([]byte, error)

func (*ExecutionContext) Load

func (ctx *ExecutionContext) Load(conn pg.Conn, je *JobExecution) error

func (*ExecutionContext) Write

func (ctx *ExecutionContext) Write(w io.Writer) error

type ExternalSubscriptionError

type ExternalSubscriptionError struct {
	Err error
}

func NewExternalSubscriptionError

func NewExternalSubscriptionError(err error) *ExternalSubscriptionError

func (ExternalSubscriptionError) Error

func (err ExternalSubscriptionError) Error() string

type FavouriteJob

type FavouriteJob struct {
	AccountId Id
	ProjectId Id
	JobId     Id
}

func (*FavouriteJob) Upsert

func (fj *FavouriteJob) Upsert(conn pg.Conn) error

type FileSet

type FileSet struct {
	Files map[string]*FileSetFile
}

func NewFileSet

func NewFileSet() *FileSet

func (*FileSet) AddFile

func (s *FileSet) AddFile(filePath string, content []byte, mode os.FileMode)

func (*FileSet) AddPrefix

func (s *FileSet) AddPrefix(prefix string)

func (*FileSet) TarArchive

func (s *FileSet) TarArchive(buf *bytes.Buffer) error

func (*FileSet) Write

func (s *FileSet) Write(rootPath string) error

type FileSetFile

type FileSetFile struct {
	Content []byte
	Mode    os.FileMode
}

type Filter

type Filter struct {
	Path           ejson.Pointer  `json:"path"`
	IsEqualTo      interface{}    `json:"is_equal_to,omitempty"`
	IsNotEqualTo   interface{}    `json:"is_not_equal_to,omitempty"`
	Matches        string         `json:"matches,omitempty"`
	MatchesRE      *regexp.Regexp `json:"-"`
	DoesNotMatch   string         `json:"does_not_match,omitempty"`
	DoesNotMatchRE *regexp.Regexp `json:"-"`
}

func (*Filter) MarshalJSON

func (pf *Filter) MarshalJSON() ([]byte, error)

func (*Filter) Match

func (f *Filter) Match(obj interface{}) bool

func (*Filter) ValidateJSON added in v1.1.0

func (f *Filter) ValidateJSON(v *ejson.Validator)

type Filters

type Filters []*Filter

func (Filters) Match

func (fs Filters) Match(obj interface{}) bool

type GlobalScope

type GlobalScope struct {
}

func NewGlobalScope

func NewGlobalScope() *GlobalScope

func (*GlobalScope) SQLCondition

func (scope *GlobalScope) SQLCondition() string

func (*GlobalScope) SQLCondition2

func (scope *GlobalScope) SQLCondition2(correlation string) string

type Id

type Id = ksuid.KSUID

func GenerateId

func GenerateId() Id

func LoadIdentityIdByName

func LoadIdentityIdByName(conn pg.Conn, name string, scope Scope) (Id, error)

type Identities

type Identities []*Identity

func (*Identities) AddFromRow

func (is *Identities) AddFromRow(row pgx.Row) error

func (*Identities) LoadAllForUpdate

func (is *Identities) LoadAllForUpdate(conn pg.Conn, scope Scope) error

func (*Identities) LoadByNames

func (is *Identities) LoadByNames(conn pg.Conn, names []string, scope Scope) error

func (*Identities) LoadByNamesForUpdate

func (is *Identities) LoadByNamesForUpdate(conn pg.Conn, names []string, scope Scope) error

func (Identities) Page

func (is Identities) Page(cursor *Cursor) *Page

type Identity

type Identity struct {
	Id           Id              `json:"id"`
	ProjectId    *Id             `json:"project_id"`
	Name         string          `json:"name"`
	Status       IdentityStatus  `json:"status"`
	ErrorMessage string          `json:"error_message,omitempty"`
	CreationTime time.Time       `json:"creation_time"`
	UpdateTime   time.Time       `json:"update_time"`
	LastUseTime  *time.Time      `json:"last_use_time,omitempty"`
	RefreshTime  *time.Time      `json:"refresh_time,omitempty"`
	Connector    string          `json:"connector"`
	Type         string          `json:"type"`
	Data         IdentityData    `json:"-"`
	RawData      json.RawMessage `json:"data"`
}

func LoadIdentityForRefresh

func LoadIdentityForRefresh(conn pg.Conn) (*Identity, error)

func (*Identity) Delete

func (i *Identity) Delete(conn pg.Conn) error

func (*Identity) FromRow

func (i *Identity) FromRow(row pgx.Row) error

func (*Identity) Insert

func (i *Identity) Insert(conn pg.Conn) error

func (*Identity) IsUsed

func (i *Identity) IsUsed(conn pg.Conn, scope Scope) (bool, error)

func (*Identity) IsUsedByJob

func (i *Identity) IsUsedByJob(conn pg.Conn, scope Scope) (bool, error)

func (*Identity) IsUsedBySubscription

func (i *Identity) IsUsedBySubscription(conn pg.Conn) (bool, error)

func (*Identity) Load

func (i *Identity) Load(conn pg.Conn, id Id, scope Scope) error

func (*Identity) LoadByName added in v1.1.0

func (i *Identity) LoadByName(conn pg.Conn, name string, scope Scope) error

func (*Identity) LoadForUpdate

func (i *Identity) LoadForUpdate(conn pg.Conn, id Id, scope Scope) error

func (*Identity) MarshalJSON

func (pi *Identity) MarshalJSON() ([]byte, error)

func (*Identity) Refreshable

func (i *Identity) Refreshable() bool

func (*Identity) SortKey

func (i *Identity) SortKey(sort string) (key string)

func (*Identity) UnmarshalJSON

func (pi *Identity) UnmarshalJSON(data []byte) error

func (*Identity) Update

func (i *Identity) Update(conn pg.Conn) error

func (*Identity) UpdateForProjectDeletion

func (i *Identity) UpdateForProjectDeletion(conn pg.Conn) error

func (*Identity) UpdateLastUseTime

func (i *Identity) UpdateLastUseTime(conn pg.Conn) error

type IdentityData

type IdentityData interface {
	ejson.Validatable

	Def() *IdentityDataDef
	Environment() map[string]string
}

type IdentityDataDef

type IdentityDataDef struct {
	Entries []*IdentityDataEntry
}

func NewIdentityDataDef

func NewIdentityDataDef() *IdentityDataDef

func (*IdentityDataDef) AddEntry

func (v *IdentityDataDef) AddEntry(e *IdentityDataEntry)

type IdentityDataEntry

type IdentityDataEntry struct {
	Key                   string
	Label                 string
	Value                 interface{}
	Type                  IdentityDataType
	EnumValues            []string
	PreselectedEnumValues []string
	MultiselectEnumSize   int // size of the multiselect html element
	Optional              bool
	Verbatim              bool
	Secret                bool
	Internal              bool // set by eventline, not by the user
}

type IdentityDataType

type IdentityDataType string
const (
	IdentityDataTypeString     IdentityDataType = "string"
	IdentityDataTypeStringList IdentityDataType = "string_list"
	IdentityDataTypeEnum       IdentityDataType = "enum"
	IdentityDataTypeEnumList   IdentityDataType = "enum_list"
	IdentityDataTypeDate       IdentityDataType = "date"
	IdentityDataTypeURI        IdentityDataType = "uri"
	IdentityDataTypeTextBlock  IdentityDataType = "text_block"
	IdentityDataTypeBoolean    IdentityDataType = "boolean"
)

type IdentityDef

type IdentityDef struct {
	Type string

	DeferredReadiness bool
	Refreshable       bool

	Data    IdentityData
	DataDef *IdentityDataDef // used when there is no actual identity
}

func NewIdentityDef

func NewIdentityDef(typeName string, dataValue IdentityData) *IdentityDef

func (*IdentityDef) DecodeData

func (idef *IdentityDef) DecodeData(data []byte) (IdentityData, error)

func (*IdentityDef) IsOAuth2

func (idef *IdentityDef) IsOAuth2() bool

type IdentityStatus

type IdentityStatus string
const (
	IdentityStatusPending IdentityStatus = "pending"
	IdentityStatusReady   IdentityStatus = "ready"
	IdentityStatusError   IdentityStatus = "error"
)

type Ids

type Ids = ksuid.KSUIDs

type Job

type Job struct {
	Id           Id        `json:"id"`
	ProjectId    Id        `json:"project_id"`
	CreationTime time.Time `json:"creation_time"`
	UpdateTime   time.Time `json:"update_time"`
	Disabled     bool      `json:"disabled,omitempty"`
	Spec         *JobSpec  `json:"spec"`
}

func (*Job) Delete

func (j *Job) Delete(conn pg.Conn, scope Scope) error

func (*Job) FromRow

func (j *Job) FromRow(row pgx.Row) error

func (*Job) Load

func (j *Job) Load(conn pg.Conn, id Id, scope Scope) error

func (*Job) LoadByName

func (j *Job) LoadByName(conn pg.Conn, name string, scope Scope) error

func (*Job) LoadForUpdate

func (j *Job) LoadForUpdate(conn pg.Conn, id Id, scope Scope) error

func (*Job) LoadRunningTimes

func (j *Job) LoadRunningTimes(conn pg.Conn, params *MetricParameters) (MetricPoints, error)

func (*Job) LoadStatusCounts

func (j *Job) LoadStatusCounts(conn pg.Conn, params *MetricParameters) (MetricPoints, error)

func (*Job) SortKey

func (j *Job) SortKey(sort string) (key string)

func (*Job) Update

func (j *Job) Update(conn pg.Conn, scope Scope) error

func (*Job) UpdateRename added in v1.1.0

func (j *Job) UpdateRename(conn pg.Conn, scope Scope) error

func (*Job) Upsert

func (j *Job) Upsert(conn pg.Conn) (Id, error)

type JobExecution

type JobExecution struct {
	Id             Id                     `json:"id"`
	ProjectId      Id                     `json:"project_id"`
	JobId          Id                     `json:"job_id"`
	JobSpec        *JobSpec               `json:"job_spec"`
	EventId        *Id                    `json:"event_id,omitempty"`
	Parameters     map[string]interface{} `json:"parameters,omitempty"`
	CreationTime   time.Time              `json:"creation_time"`
	UpdateTime     time.Time              `json:"update_time"`
	ScheduledTime  time.Time              `json:"scheduled_time,omitempty"`
	Status         JobExecutionStatus     `json:"status"`
	StartTime      *time.Time             `json:"start_time,omitempty"`
	EndTime        *time.Time             `json:"end_time,omitempty"`
	RefreshTime    *time.Time             `json:"refresh_time,omitempty"`
	ExpirationTime *time.Time             `json:"expiration_time,omitempty"`
	FailureMessage string                 `json:"failure_message,omitempty"`
}

func LoadDeadJobExecution added in v1.0.0

func LoadDeadJobExecution(conn pg.Conn, timeout int) (*JobExecution, error)

func LoadJobExecutionForScheduling

func LoadJobExecutionForScheduling(conn pg.Conn) (*JobExecution, error)

func LoadLastJobExecutionFinishedBefore

func LoadLastJobExecutionFinishedBefore(conn pg.Conn, je *JobExecution) (*JobExecution, error)

func (*JobExecution) Duration

func (je *JobExecution) Duration() *time.Duration

func (*JobExecution) Finished

func (je *JobExecution) Finished() bool

func (*JobExecution) FromRow

func (je *JobExecution) FromRow(row pgx.Row) error

func (*JobExecution) Insert

func (je *JobExecution) Insert(conn pg.Conn) error

func (*JobExecution) Load

func (je *JobExecution) Load(conn pg.Conn, id Id, scope Scope) error

func (*JobExecution) LoadForUpdate

func (je *JobExecution) LoadForUpdate(conn pg.Conn, id Id, scope Scope) error

func (*JobExecution) LoadForUpdateNoScope added in v1.0.0

func (je *JobExecution) LoadForUpdateNoScope(conn pg.Conn, id Id) error

func (*JobExecution) SortKey

func (je *JobExecution) SortKey(sort string) (key string)

func (*JobExecution) Update

func (je *JobExecution) Update(conn pg.Conn) error

func (*JobExecution) UpdateRefreshTime added in v1.0.0

func (je *JobExecution) UpdateRefreshTime(conn pg.Conn) error

type JobExecutionAbortedError

type JobExecutionAbortedError struct {
	Id Id
}

func (*JobExecutionAbortedError) Error

func (err *JobExecutionAbortedError) Error() string

type JobExecutionFinishedError

type JobExecutionFinishedError struct {
	Id Id
}

func (*JobExecutionFinishedError) Error

func (err *JobExecutionFinishedError) Error() string

type JobExecutionInput

type JobExecutionInput struct {
	Parameters    map[string]interface{} `json:"-"`
	RawParameters json.RawMessage        `json:"parameters"`
}

func (*JobExecutionInput) MarshalJSON

func (pi *JobExecutionInput) MarshalJSON() ([]byte, error)

func (*JobExecutionInput) UnmarshalJSON

func (pi *JobExecutionInput) UnmarshalJSON(data []byte) error

type JobExecutionNotFinishedError

type JobExecutionNotFinishedError struct {
	Id Id
}

func (*JobExecutionNotFinishedError) Error

func (err *JobExecutionNotFinishedError) Error() string

type JobExecutionPageOptions

type JobExecutionPageOptions struct {
	JobId *Id
}

type JobExecutionStatus

type JobExecutionStatus string
const (
	JobExecutionStatusCreated    JobExecutionStatus = "created"
	JobExecutionStatusStarted    JobExecutionStatus = "started"
	JobExecutionStatusAborted    JobExecutionStatus = "aborted"
	JobExecutionStatusSuccessful JobExecutionStatus = "successful"
	JobExecutionStatusFailed     JobExecutionStatus = "failed"
)

type JobExecutions

type JobExecutions []*JobExecution

func (*JobExecutions) AddFromRow

func (jes *JobExecutions) AddFromRow(row pgx.Row) error

func (*JobExecutions) LoadByEvent

func (jes *JobExecutions) LoadByEvent(conn pg.Conn, eventId Id) error

func (JobExecutions) Page

func (jes JobExecutions) Page(cursor *Cursor) *Page

type JobPageOptions

type JobPageOptions struct {
	ExcludeFavouriteJobAccountId *Id
}

type JobRenamingData added in v1.1.0

type JobRenamingData struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

func (*JobRenamingData) ValidateJSON added in v1.1.0

func (data *JobRenamingData) ValidateJSON(v *ejson.Validator)

type JobRunner

type JobRunner struct {
	Name          string           `json:"name"`
	Parameters    RunnerParameters `json:"-"`
	RawParameters json.RawMessage  `json:"parameters"`
	Identity      string           `json:"identity,omitempty"`
}

func (*JobRunner) MarshalJSON

func (pr *JobRunner) MarshalJSON() ([]byte, error)

func (*JobRunner) UnmarshalJSON

func (pr *JobRunner) UnmarshalJSON(data []byte) error

func (*JobRunner) ValidateJSON added in v1.1.0

func (r *JobRunner) ValidateJSON(v *ejson.Validator)

type JobSpec

type JobSpec struct {
	Name        string `json:"name"`
	Description string `json:"description"`

	Trigger    *Trigger   `json:"trigger,omitempty"`
	Parameters Parameters `json:"parameters,omitempty"`

	Runner     *JobRunner `json:"runner"`
	Concurrent bool       `json:"concurrent,omitempty"`

	Retention int `json:"retention,omitempty"` // days

	Identities  []string          `json:"identities,omitempty"`
	Environment map[string]string `json:"environment,omitempty"`
	Steps       Steps             `json:"steps"`
}

func (*JobSpec) IdentityNames

func (spec *JobSpec) IdentityNames() []string

func (*JobSpec) ParseYAML

func (spec *JobSpec) ParseYAML(data []byte) error

func (JobSpec) ValidateJSON added in v1.1.0

func (spec JobSpec) ValidateJSON(v *ejson.Validator)

type JobSpecs added in v1.0.0

type JobSpecs []*JobSpec

type JobStats

type JobStats struct {
	JobId        Id             `json:"job_id"`
	NbExecutions int            `json:"nb_executions"`
	DurationP50  *time.Duration `json:"duration_p50,omitempty"`
	SuccessRatio float64        `json:"success_ratio"` // last 7 days
}

func (*JobStats) FromRow

func (js *JobStats) FromRow(row pgx.Row) error

func (*JobStats) SuccessPercentage

func (js *JobStats) SuccessPercentage() float64

func (*JobStats) SuccessPercentageString

func (js *JobStats) SuccessPercentageString() string

type JobStatsList

type JobStatsList []*JobStats

func (*JobStatsList) AddFromRow

func (jss *JobStatsList) AddFromRow(row pgx.Row) error

type Jobs

type Jobs []*Job

func LoadFavouriteJobs

func LoadFavouriteJobs(conn pg.Conn, scope Scope) (Jobs, error)

func (*Jobs) AddFromRow

func (js *Jobs) AddFromRow(row pgx.Row) error

func (*Jobs) LoadByIdentityName

func (js *Jobs) LoadByIdentityName(conn pg.Conn, name string, scope Scope) error

func (Jobs) Page

func (js Jobs) Page(cursor *Cursor) *Page

type MetricGranularity

type MetricGranularity string
const (
	MetricGranularityDay  MetricGranularity = "day"
	MetricGranularityHour MetricGranularity = "hour"
)

type MetricParameters

type MetricParameters struct {
	Start       time.Time
	End         time.Time
	Granularity MetricGranularity
}

type MetricPoint

type MetricPoint []interface{}

func (*MetricPoint) FromRow

func (p *MetricPoint) FromRow(row pgx.Row) error

type MetricPoints

type MetricPoints []MetricPoint

func (*MetricPoints) AddFromRow

func (ps *MetricPoints) AddFromRow(row pgx.Row) error

type NewAPIKey

type NewAPIKey struct {
	Name string `json:"name"`
}

func (*NewAPIKey) ValidateJSON added in v1.1.0

func (nk *NewAPIKey) ValidateJSON(v *ejson.Validator)

type NewAccount

type NewAccount struct {
	Username             string      `json:"username"`
	Password             string      `json:"password"`
	PasswordConfirmation string      `json:"password_confirmation"`
	Role                 AccountRole `json:"role"`
}

func (*NewAccount) ValidateJSON added in v1.1.0

func (na *NewAccount) ValidateJSON(v *ejson.Validator)

type NewEvent

type NewEvent struct {
	EventTime time.Time       `json:"event_time"`
	Connector string          `json:"connector"`
	Name      string          `json:"name"`
	Data      EventData       `json:"-"`
	RawData   json.RawMessage `json:"data"`
}

func (*NewEvent) UnmarshalJSON

func (pne *NewEvent) UnmarshalJSON(data []byte) error

func (*NewEvent) ValidateJSON added in v1.1.0

func (ne *NewEvent) ValidateJSON(v *ejson.Validator)

type NewIdentity

type NewIdentity struct {
	Name      string          `json:"name"`
	Connector string          `json:"connector"`
	Type      string          `json:"type"`
	Data      IdentityData    `json:"-"`
	RawData   json.RawMessage `json:"data"`
}

func (*NewIdentity) IsOAuth2 added in v1.1.0

func (i *NewIdentity) IsOAuth2() bool

func (*NewIdentity) MarshalJSON

func (pni *NewIdentity) MarshalJSON() ([]byte, error)

func (*NewIdentity) UnmarshalJSON

func (pni *NewIdentity) UnmarshalJSON(data []byte) error

func (*NewIdentity) ValidateJSON added in v1.1.0

func (ni *NewIdentity) ValidateJSON(v *ejson.Validator)

type NewProject

type NewProject struct {
	Name string `json:"name"`
}

func (*NewProject) ValidateJSON added in v1.1.0

func (np *NewProject) ValidateJSON(v *ejson.Validator)

type NewSession

type NewSession struct {
	Data            *SessionData     `json:"data"`
	AccountRole     AccountRole      `json:"account_role"`
	AccountSettings *AccountSettings `json:"account_settings"`
}

type Notification

type Notification struct {
	Id               Id
	ProjectId        Id
	Recipients       []string
	Message          []byte
	NextDeliveryTime time.Time
	DeliveryDelay    int // seconds
}

func LoadNotificationForDelivery

func LoadNotificationForDelivery(conn pg.Conn) (*Notification, error)

func (*Notification) Delete

func (n *Notification) Delete(conn pg.Conn) error

func (*Notification) FromRow

func (n *Notification) FromRow(row pgx.Row) error

func (*Notification) Insert

func (n *Notification) Insert(conn pg.Conn) error

func (*Notification) Update

func (n *Notification) Update(conn pg.Conn) error

type NullProjectScope

type NullProjectScope struct {
}

func (*NullProjectScope) SQLCondition

func (scope *NullProjectScope) SQLCondition() string

func (*NullProjectScope) SQLCondition2

func (scope *NullProjectScope) SQLCondition2(correlation string) string

type OAuth2IdentityData

type OAuth2IdentityData interface {
	IdentityData

	RedirectionURI(*http.Client, string, string) (string, error)
	FetchTokenData(*http.Client, string, string) error
}

type OptionalConnector

type OptionalConnector interface {
	Connector

	Enabled() bool
}

The optional aspect of the connector is related to events only. But at this point I do not have a better idea for a name.

type Order

type Order string
const (
	OrderAsc  Order = "asc"
	OrderDesc Order = "desc"
)

type Page

type Page struct {
	Elements []PageElement `json:"elements"`
	Previous *Cursor       `json:"previous,omitempty"`
	Next     *Cursor       `json:"next,omitempty"`
}

func LoadAPIKeyPage

func LoadAPIKeyPage(conn pg.Conn, cursor *Cursor, scope Scope) (*Page, error)

func LoadAccountPage

func LoadAccountPage(conn pg.Conn, cursor *Cursor) (*Page, error)

func LoadEventPage

func LoadEventPage(conn pg.Conn, cursor *Cursor, scope Scope) (*Page, error)

func LoadIdentityPage

func LoadIdentityPage(conn pg.Conn, cursor *Cursor, scope Scope) (*Page, error)

func LoadJobExecutionPage

func LoadJobExecutionPage(conn pg.Conn, options JobExecutionPageOptions, cursor *Cursor, scope Scope) (*Page, error)

func LoadJobPage

func LoadJobPage(conn pg.Conn, options JobPageOptions, cursor *Cursor, scope Scope) (*Page, error)

func LoadProjectPage

func LoadProjectPage(conn pg.Conn, cursor *Cursor) (*Page, error)

func NewPage

func NewPage(cursor *Cursor, elements []PageElement, sorts Sorts) *Page

func (*Page) HasPreviousOrNextURI

func (p *Page) HasPreviousOrNextURI() bool

func (*Page) IsEmpty

func (p *Page) IsEmpty() bool

func (*Page) NextURI

func (p *Page) NextURI() string

func (*Page) PreviousURI

func (p *Page) PreviousURI() string

type PageElement

type PageElement interface {
	SortKey(string) string
}

type Parameter

type Parameter struct {
	Name        string          `json:"name"`
	Type        ParameterType   `json:"type"`
	Values      []string        `json:"values,omitempty"`
	Default     interface{}     `json:"-"`
	RawDefault  json.RawMessage `json:"default,omitempty"`
	Description string          `json:"description,omitempty"`
	Environment string          `json:"environment,omitempty"`
}

func (*Parameter) CheckValue

func (p *Parameter) CheckValue(v *ejson.Validator, token string, value interface{}) interface{}

func (*Parameter) Label

func (p *Parameter) Label() string

func (*Parameter) MarshalJSON

func (pp *Parameter) MarshalJSON() ([]byte, error)

func (*Parameter) UnmarshalJSON

func (pp *Parameter) UnmarshalJSON(data []byte) error

func (*Parameter) ValidateJSON added in v1.1.0

func (p *Parameter) ValidateJSON(v *ejson.Validator)

func (*Parameter) ValueString

func (p *Parameter) ValueString(value interface{}) (s string)

type ParameterType

type ParameterType string
const (
	ParameterTypeNumber  ParameterType = "number"
	ParameterTypeInteger ParameterType = "integer"
	ParameterTypeString  ParameterType = "string"
	ParameterTypeBoolean ParameterType = "boolean"
)

type Parameters

type Parameters []*Parameter

func (Parameters) CheckValues

func (ps Parameters) CheckValues(v *ejson.Validator, token string, values map[string]interface{})

func (Parameters) Parameter

func (ps Parameters) Parameter(name string) *Parameter

type Project

type Project struct {
	Id           Id        `json:"id"`
	Name         string    `json:"name"`
	CreationTime time.Time `json:"creation_time"`
	UpdateTime   time.Time `json:"update_time"`
}

func LoadMostRecentProject added in v1.0.8

func LoadMostRecentProject(conn pg.Conn) (*Project, error)

func (*Project) Delete

func (p *Project) Delete(conn pg.Conn) error

func (*Project) FromRow

func (p *Project) FromRow(row pgx.Row) error

func (*Project) Insert

func (p *Project) Insert(conn pg.Conn) error

func (*Project) Load

func (p *Project) Load(conn pg.Conn, id Id) error

func (*Project) LoadByName

func (p *Project) LoadByName(conn pg.Conn, name string) error

func (*Project) LoadForUpdate

func (p *Project) LoadForUpdate(conn pg.Conn, id Id) error

func (*Project) SortKey

func (p *Project) SortKey(sort string) (key string)

func (*Project) Update

func (p *Project) Update(conn pg.Conn) error

type ProjectNotificationSettings

type ProjectNotificationSettings struct {
	Id                     Id       `json:"id"` // ignored in input
	OnSuccessfulJob        bool     `json:"on_successful_job,omitempty"`
	OnFirstSuccessfulJob   bool     `json:"on_first_successful_job,omitempty"`
	OnFailedJob            bool     `json:"on_failed_job,omitempty"`
	OnAbortedJob           bool     `json:"on_aborted_job,omitempty"`
	OnIdentityRefreshError bool     `json:"on_identity_refresh_error,omitempty"`
	EmailAddresses         []string `json:"email_addresses"`
}

func (*ProjectNotificationSettings) Check

func (ps *ProjectNotificationSettings) Check(v *ejson.Validator)

func (*ProjectNotificationSettings) CheckEmailAddresses added in v1.0.0

func (ps *ProjectNotificationSettings) CheckEmailAddresses(v *ejson.Validator, allowedDomains []string)

func (*ProjectNotificationSettings) FromRow

func (ps *ProjectNotificationSettings) FromRow(row pgx.Row) error

func (*ProjectNotificationSettings) Insert

func (ps *ProjectNotificationSettings) Insert(conn pg.Conn) error

func (*ProjectNotificationSettings) Load

func (ps *ProjectNotificationSettings) Load(conn pg.Conn, id Id) error

func (*ProjectNotificationSettings) Update

func (ps *ProjectNotificationSettings) Update(conn pg.Conn) error

type ProjectScope

type ProjectScope struct {
	ProjectId Id
}

func (*ProjectScope) SQLCondition

func (scope *ProjectScope) SQLCondition() string

func (*ProjectScope) SQLCondition2

func (scope *ProjectScope) SQLCondition2(correlation string) string

type ProjectSettings

type ProjectSettings struct {
	Id         Id     `json:"id"` // Ignored in input
	CodeHeader string `json:"code_header"`
}

func (*ProjectSettings) FromRow

func (ps *ProjectSettings) FromRow(row pgx.Row) error

func (*ProjectSettings) Insert

func (ps *ProjectSettings) Insert(conn pg.Conn) error

func (*ProjectSettings) Load

func (ps *ProjectSettings) Load(conn pg.Conn, id Id) error

func (*ProjectSettings) Update

func (ps *ProjectSettings) Update(conn pg.Conn) error

func (*ProjectSettings) ValidateJSON added in v1.1.0

func (ps *ProjectSettings) ValidateJSON(v *ejson.Validator)

type Projects

type Projects []*Project

func (*Projects) AddFromRow

func (ps *Projects) AddFromRow(row pgx.Row) error

func (*Projects) LoadAll

func (ps *Projects) LoadAll(conn pg.Conn) error

func (Projects) Page

func (ps Projects) Page(cursor *Cursor) *Page

type RawIdentities added in v1.1.0

type RawIdentities []*RawIdentity

type RawIdentity added in v1.1.0

type RawIdentity Identity

type RawNewIdentity added in v1.1.0

type RawNewIdentity NewIdentity

type RefreshableOAuth2IdentityData

type RefreshableOAuth2IdentityData interface {
	OAuth2IdentityData

	Refresh(*http.Client) error
	RefreshTime() time.Time
}

type Runner

type Runner struct {
	Log       *log.Logger
	Pg        *pg.Client
	Cfg       RunnerCfg
	Behaviour RunnerBehaviour

	JobExecution     *JobExecution
	StepExecutions   StepExecutions
	ExecutionContext *ExecutionContext
	Project          *Project
	ProjectSettings  *ProjectSettings

	RunnerIdentity *Identity

	Environment map[string]string
	FileSet     *FileSet
	Scope       Scope

	StopChan <-chan struct{}
	Wg       *sync.WaitGroup
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(data RunnerInitData) (*Runner, error)

func (*Runner) HandleError

func (r *Runner) HandleError(err error)

func (*Runner) HandleInterruption

func (r *Runner) HandleInterruption()

func (*Runner) Start

func (r *Runner) Start() error

func (*Runner) StepCommand

func (r *Runner) StepCommand(se *StepExecution, s *Step, rootPath string) (name string, args []string)

func (*Runner) StepCommandString added in v1.0.0

func (r *Runner) StepCommandString(se *StepExecution, s *Step, rootPath string) string

func (*Runner) Stopping

func (r *Runner) Stopping() bool

func (*Runner) UpdateStepExecutionOutput

func (r *Runner) UpdateStepExecutionOutput(se *StepExecution, data []byte) error

type RunnerBehaviour

type RunnerBehaviour interface {
	DirPath() string

	Init(ctx context.Context) error
	Terminate()

	ExecuteStep(context.Context, *StepExecution, *Step, io.WriteCloser, io.WriteCloser) error
}

type RunnerCfg

type RunnerCfg interface {
	ejson.Validatable
}

type RunnerData

type RunnerData struct {
	JobExecution     *JobExecution
	StepExecutions   StepExecutions
	ExecutionContext *ExecutionContext
	Project          *Project
	ProjectSettings  *ProjectSettings
}

func (*RunnerData) Environment

func (rd *RunnerData) Environment() map[string]string

func (*RunnerData) FileSet

func (rd *RunnerData) FileSet() (*FileSet, error)

type RunnerDef

type RunnerDef struct {
	Name                  string
	Cfg                   RunnerCfg
	InstantiateParameters func() RunnerParameters
	InstantiateBehaviour  func(*Runner) RunnerBehaviour
}

type RunnerInitData

type RunnerInitData struct {
	Log *log.Logger
	Pg  *pg.Client

	Def  *RunnerDef
	Cfg  RunnerCfg
	Data *RunnerData

	TerminationChan chan<- Id

	RefreshInterval time.Duration

	StopChan <-chan struct{}
	Wg       *sync.WaitGroup
}

type RunnerParameters

type RunnerParameters interface {
	ejson.Validatable
}

type Scope

type Scope interface {
	SQLCondition() string
	SQLCondition2(string) string
}

func NewAccountProjectScope

func NewAccountProjectScope(accountId, projectId Id) Scope

func NewAccountScope

func NewAccountScope(accountId Id) Scope

func NewNullProjectScope

func NewNullProjectScope() Scope

func NewProjectScope

func NewProjectScope(projectId Id) Scope

type Session

type Session struct {
	Id              Id               `json:"id"`
	AccountId       Id               `json:"account_id"`
	CreationTime    time.Time        `json:"creation_time"`
	UpdateTime      time.Time        `json:"update_time"`
	Data            *SessionData     `json:"data"`
	AccountRole     AccountRole      `json:"account_role"`
	AccountSettings *AccountSettings `json:"account_settings"`
}

func (*Session) Delete

func (s *Session) Delete(conn pg.Conn) error

func (*Session) FromRow

func (s *Session) FromRow(row pgx.Row) error

func (*Session) Insert

func (s *Session) Insert(conn pg.Conn) error

func (*Session) LoadUpdate

func (s *Session) LoadUpdate(conn pg.Conn, id Id) error

func (*Session) UpdateAccountSettings

func (s *Session) UpdateAccountSettings(conn pg.Conn) error

func (*Session) UpdateData

func (s *Session) UpdateData(conn pg.Conn) error

type SessionData

type SessionData struct {
	ProjectId *Id `json:"project_id,omitempty"`
}

type Shebang

type Shebang struct {
	Interpreter string
	Argument    string
}

func (*Shebang) Parse

func (s *Shebang) Parse(data string) error

type Sorts

type Sorts struct {
	Sorts   map[string]string
	Default string
}
var APIKeySorts Sorts = Sorts{
	Sorts: map[string]string{
		"id":   "id",
		"name": "name",
	},

	Default: "name",
}
var AccountSorts Sorts = Sorts{
	Sorts: map[string]string{
		"id":       "id",
		"username": "username",
	},

	Default: "username",
}
var DefaultSorts Sorts = Sorts{
	Sorts: map[string]string{
		"id": "id",
	},

	Default: "id",
}
var EventSorts Sorts = Sorts{
	Sorts: map[string]string{
		"id":         "id",
		"event_time": "event_time",
	},

	Default: "event_time",
}
var IdentitySorts Sorts = Sorts{
	Sorts: map[string]string{
		"id":   "id",
		"name": "name",
	},

	Default: "name",
}
var JobExecutionSorts Sorts = Sorts{
	Sorts: map[string]string{
		"id":             "id",
		"scheduled_time": "scheduled_time",
	},

	Default: "scheduled_time",
}
var JobSorts Sorts = Sorts{
	Sorts: map[string]string{
		"id":   "id",
		"name": "spec->>'name'",
	},

	Default: "name",
}
var ProjectSorts Sorts = Sorts{
	Sorts: map[string]string{
		"id":   "id",
		"name": "name",
	},

	Default: "name",
}

func (Sorts) Column

func (ss Sorts) Column(name string) string

func (Sorts) Contains

func (ss Sorts) Contains(name string) bool

type Step

type Step struct {
	Label string `json:"label,omitempty"`

	Code    string       `json:"code,omitempty"`
	Command *StepCommand `json:"command,omitempty"`
	Script  *StepScript  `json:"script,omitempty"`

	OnFailure StepFailureAction `json:"on_failure,omitempty"`
}

func (*Step) AbortOnFailure

func (s *Step) AbortOnFailure() bool

func (*Step) ValidateJSON added in v1.1.0

func (s *Step) ValidateJSON(v *ejson.Validator)

type StepCommand

type StepCommand struct {
	Name      string   `json:"name"`
	Arguments []string `json:"arguments,omitempty"`
}

func (*StepCommand) ValidateJSON added in v1.1.0

func (s *StepCommand) ValidateJSON(v *ejson.Validator)

type StepExecution

type StepExecution struct {
	Id             Id                  `json:"id"`
	ProjectId      Id                  `json:"project_id"`
	JobExecutionId Id                  `json:"job_execution_id"`
	Position       int                 `json:"position"`
	Status         StepExecutionStatus `json:"status"`
	StartTime      *time.Time          `json:"start_time,omitempty"`
	EndTime        *time.Time          `json:"end_time,omitempty"`
	FailureMessage string              `json:"failure_message,omitempty"`
	Output         string              `json:"output,omitempty"`
}

func (*StepExecution) ClearOutput

func (se *StepExecution) ClearOutput(conn pg.Conn) error

func (*StepExecution) Duration

func (se *StepExecution) Duration() *time.Duration

func (*StepExecution) Finished

func (se *StepExecution) Finished() bool

func (*StepExecution) FromRow

func (se *StepExecution) FromRow(row pgx.Row) error

func (*StepExecution) Insert

func (se *StepExecution) Insert(conn pg.Conn) error

func (*StepExecution) Load

func (se *StepExecution) Load(conn pg.Conn, id Id, scope Scope) error

func (*StepExecution) Update

func (se *StepExecution) Update(conn pg.Conn) error

func (*StepExecution) UpdateOutput

func (se *StepExecution) UpdateOutput(conn pg.Conn, data []byte) error

type StepExecutionStatus

type StepExecutionStatus string
const (
	StepExecutionStatusCreated    StepExecutionStatus = "created"
	StepExecutionStatusStarted    StepExecutionStatus = "started"
	StepExecutionStatusAborted    StepExecutionStatus = "aborted"
	StepExecutionStatusSuccessful StepExecutionStatus = "successful"
	StepExecutionStatusFailed     StepExecutionStatus = "failed"
)

type StepExecutions

type StepExecutions []*StepExecution

func (*StepExecutions) AddFromRow

func (ses *StepExecutions) AddFromRow(row pgx.Row) error

func (*StepExecutions) LoadByJobExecutionId

func (ses *StepExecutions) LoadByJobExecutionId(conn pg.Conn, jeId Id) error

func (*StepExecutions) LoadByJobExecutionIdForUpdate

func (ses *StepExecutions) LoadByJobExecutionIdForUpdate(conn pg.Conn, jeId Id) error

func (*StepExecutions) LoadByJobExecutionIdWithTruncatedOutput added in v1.0.7

func (ses *StepExecutions) LoadByJobExecutionIdWithTruncatedOutput(conn pg.Conn, jeId Id, maxOutputSize int, truncationString string) error

type StepFailureAction

type StepFailureAction string
const (
	StepFailureActionAbort    StepFailureAction = "abort"
	StepFailureActionContinue StepFailureAction = "continue"
)

type StepFailureError

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

func NewStepFailureError

func NewStepFailureError(err error) *StepFailureError

func (*StepFailureError) Error

func (err *StepFailureError) Error() string

func (*StepFailureError) Unwrap

func (err *StepFailureError) Unwrap() error

type StepScript

type StepScript struct {
	Path      string   `json:"path"`
	Arguments []string `json:"arguments,omitempty"`

	Content string `json:"content,omitempty"` // content of the script file
}

func (*StepScript) ValidateJSON added in v1.1.0

func (s *StepScript) ValidateJSON(v *ejson.Validator)

type Steps

type Steps []*Step

type SubscribableConnector

type SubscribableConnector interface {
	Connector

	Subscribe(pg.Conn, *SubscriptionContext) error
	Unsubscribe(pg.Conn, *SubscriptionContext) error
}

type Subscription

type Subscription struct {
	Id             Id
	ProjectId      *Id
	JobId          *Id
	IdentityId     *Id
	Connector      string
	Event          string
	Parameters     SubscriptionParameters
	CreationTime   time.Time
	Status         SubscriptionStatus
	UpdateDelay    int // seconds
	LastUpdateTime *time.Time
	NextUpdateTime *time.Time
}

func LoadSubscriptionForProcessing

func LoadSubscriptionForProcessing(conn pg.Conn) (*Subscription, error)

func (*Subscription) Delete

func (s *Subscription) Delete(conn pg.Conn) error

func (*Subscription) EventDef

func (s *Subscription) EventDef() *EventDef

func (*Subscription) FromRow

func (s *Subscription) FromRow(row pgx.Row) error

func (*Subscription) Insert

func (s *Subscription) Insert(conn pg.Conn) error

func (*Subscription) Load

func (s *Subscription) Load(conn pg.Conn, id Id) error

func (*Subscription) LoadByJobForUpdate

func (s *Subscription) LoadByJobForUpdate(conn pg.Conn, jobId Id, scope Scope) error

func (*Subscription) NewEvent

func (s *Subscription) NewEvent(cname, ename string, etime *time.Time, data EventData) *Event

func (*Subscription) Update

func (s *Subscription) Update(conn pg.Conn) error

func (*Subscription) UpdateOp

func (s *Subscription) UpdateOp(conn pg.Conn) error

type SubscriptionContext

type SubscriptionContext struct {
	Subscription *Subscription
	Identity     *Identity
	Job          *Job

	Scope Scope
}

func (*SubscriptionContext) Load

func (sctx *SubscriptionContext) Load(conn pg.Conn, subscription *Subscription) error

type SubscriptionParameters

type SubscriptionParameters interface {
	ejson.Validatable
}

type SubscriptionStatus

type SubscriptionStatus string
const (
	SubscriptionStatusInactive    SubscriptionStatus = "inactive"
	SubscriptionStatusActive      SubscriptionStatus = "active"
	SubscriptionStatusTerminating SubscriptionStatus = "terminating"
)

type Subscriptions

type Subscriptions []*Subscription

func (*Subscriptions) AddFromRow

func (ss *Subscriptions) AddFromRow(row pgx.Row) error

func (*Subscriptions) LoadAllForUpdate

func (ss *Subscriptions) LoadAllForUpdate(conn pg.Conn, scope Scope) error

type Trigger

type Trigger struct {
	Event         EventRef               `json:"event"`
	Parameters    SubscriptionParameters `json:"-"`
	RawParameters json.RawMessage        `json:"parameters,omitempty"`
	Identity      string                 `json:"identity,omitempty"`
	Filters       Filters                `json:"filters,omitempty"`
}

func (*Trigger) MarshalJSON

func (pt *Trigger) MarshalJSON() ([]byte, error)

func (*Trigger) UnmarshalJSON

func (pt *Trigger) UnmarshalJSON(data []byte) error

func (*Trigger) ValidateJSON added in v1.1.0

func (t *Trigger) ValidateJSON(v *ejson.Validator)

type UnknownAPIKeyError

type UnknownAPIKeyError struct {
	Id *Id
}

func (UnknownAPIKeyError) Error

func (err UnknownAPIKeyError) Error() string

type UnknownAccountError

type UnknownAccountError struct {
	Id Id
}

func (UnknownAccountError) Error

func (err UnknownAccountError) Error() string

type UnknownConnectorDefError

type UnknownConnectorDefError struct {
	Name string
}

func (UnknownConnectorDefError) Error

func (err UnknownConnectorDefError) Error() string

type UnknownEventDefError

type UnknownEventDefError struct {
	Connector string
	Name      string
}

func (UnknownEventDefError) Error

func (err UnknownEventDefError) Error() string

type UnknownEventError

type UnknownEventError struct {
	Id Id
}

func (UnknownEventError) Error

func (err UnknownEventError) Error() string

type UnknownIdentityDefError

type UnknownIdentityDefError struct {
	Connector string
	Type      string
}

func (UnknownIdentityDefError) Error

func (err UnknownIdentityDefError) Error() string

type UnknownIdentityError

type UnknownIdentityError struct {
	Id Id
}

func (UnknownIdentityError) Error

func (err UnknownIdentityError) Error() string

type UnknownIdentityNameError added in v1.1.0

type UnknownIdentityNameError struct {
	Name string
}

func (UnknownIdentityNameError) Error added in v1.1.0

func (err UnknownIdentityNameError) Error() string

type UnknownJobError

type UnknownJobError struct {
	Id Id
}

func (UnknownJobError) Error

func (err UnknownJobError) Error() string

type UnknownJobExecutionError

type UnknownJobExecutionError struct {
	Id Id
}

func (UnknownJobExecutionError) Error

func (err UnknownJobExecutionError) Error() string

type UnknownJobNameError

type UnknownJobNameError struct {
	Name string
}

func (UnknownJobNameError) Error

func (err UnknownJobNameError) Error() string

type UnknownJobSubscriptionError

type UnknownJobSubscriptionError struct {
	JobId Id
}

func (UnknownJobSubscriptionError) Error

func (err UnknownJobSubscriptionError) Error() string

type UnknownProjectError

type UnknownProjectError struct {
	Id Id
}

func (UnknownProjectError) Error

func (err UnknownProjectError) Error() string

type UnknownProjectNameError

type UnknownProjectNameError struct {
	Name string
}

func (UnknownProjectNameError) Error

func (err UnknownProjectNameError) Error() string

type UnknownSessionError

type UnknownSessionError struct {
	Id Id
}

func (UnknownSessionError) Error

func (err UnknownSessionError) Error() string

type UnknownStepExecutionError

type UnknownStepExecutionError struct {
	Id Id
}

func (UnknownStepExecutionError) Error

func (err UnknownStepExecutionError) Error() string

type UnknownSubscriptionError

type UnknownSubscriptionError struct {
	Id Id
}

func (UnknownSubscriptionError) Error

func (err UnknownSubscriptionError) Error() string

type UnknownUsernameError

type UnknownUsernameError struct {
	Username string
}

func (UnknownUsernameError) Error

func (err UnknownUsernameError) Error() string

type Worker

type Worker struct {
	Name string
	Cfg  WorkerCfg
	Log  *log.Logger
	Pg   *pg.Client
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(name string, cfg WorkerCfg) *Worker

func (*Worker) Start

func (w *Worker) Start() error

func (*Worker) Stopping

func (w *Worker) Stopping() bool

func (*Worker) WakeUp

func (w *Worker) WakeUp()

type WorkerBehaviour

type WorkerBehaviour interface {
	Init(*Worker)
	Start() error
	Stop()
	ProcessJob() (bool, error)
}

type WorkerCfg

type WorkerCfg struct {
	Log *log.Logger `json:"-"`
	Pg  *pg.Client  `json:"-"`

	Behaviour WorkerBehaviour `json:"-"`

	Disabled bool `json:"disabled"`

	InitialDelay  int `json:"initial_delay"`  // millisecond
	ErrorDelay    int `json:"error_delay"`    // millisecond
	SleepDuration int `json:"sleep_duration"` // millisecond

	NotificationChan chan<- interface{} `json:"-"`
	StopChan         <-chan struct{}    `json:"-"`
	Wg               *sync.WaitGroup    `json:"-"`
}

Jump to

Keyboard shortcuts

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