models

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

This section is empty.

Variables

This section is empty.

Functions

func AggregateLogs

func AggregateLogs(db *sql.DB) (int, error)

aggregate log parts with final state which are older then 5 min or log parts older then 1 day

func CompareUserWithJobUser

func CompareUserWithJobUser(user auth.User, jobUser JSONB) (bool, error)

func FailExpiredJobs

func FailExpiredJobs(db *sql.DB) (affectedJobs int64, err error)

fail jobs which the timeout + 60 sec has exceeded and still in queued or executing status

func FailQueuedJobs

func FailQueuedJobs(db *sql.DB) (affectedJobs int64, err error)

fail jobs which no heartbeat was send back after created_at + 60 sec

func IsConcurrencySafe

func IsConcurrencySafe(db Db, messageId string, agentId string) (bool, error)

func ProcessLogReply

func ProcessLogReply(db *sql.DB, reply *arc.Reply, agentId string, concurrencySafe bool) error

func ProcessRegistration

func ProcessRegistration(db *sql.DB, reg *arc.Registration, agentId string, concurrencySafe bool) error

func ProcessTags

func ProcessTags(db *sql.DB, authorization *auth.Authorization, agentId string, tags map[string]string) error

func PruneJobs

func PruneJobs(db *sql.DB) (affectedJobs int64, err error)

delete jobs which are older than 30 days

func PruneLocks

func PruneLocks(db Db) (int64, error)

Types

type Agent

type Agent struct {
	DisplayName  string    `json:"display_name"`
	AgentID      string    `json:"agent_id"`
	Project      string    `json:"project"`
	Organization string    `json:"organization"`
	Facts        JSONB     `json:"facts,omitempty"`
	Tags         JSONB     `json:"tags,omitempty"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	UpdatedWith  string    `json:"updated_with"`
	UpdatedBy    string    `json:"updated_by"`
}

func (*Agent) AddTagAuthorized

func (agent *Agent) AddTagAuthorized(db Db, authorization *auth.Authorization, tagKey string, tagValue string) error

func (*Agent) DeleteAuthorized

func (agent *Agent) DeleteAuthorized(db Db, authorization *auth.Authorization) error

func (*Agent) DeleteTagAuthorized

func (agent *Agent) DeleteTagAuthorized(db Db, authorization *auth.Authorization, tagKey string) error

func (*Agent) Example

func (agent *Agent) Example()

func (*Agent) FromRegistration

func (agent *Agent) FromRegistration(reg *arc.Registration, agentId string) error

func (*Agent) Get

func (agent *Agent) Get(db Db) error

func (*Agent) GetAuthorizedAndShowFacts

func (agent *Agent) GetAuthorizedAndShowFacts(db Db, authorization *auth.Authorization, showFacts []string) error

func (*Agent) Save

func (agent *Agent) Save(db Db) error

func (*Agent) Update

func (agent *Agent) Update(db Db) error

type Agents

type Agents []Agent

func (*Agents) CreateAndSaveAgentExamples

func (agents *Agents) CreateAndSaveAgentExamples(db *sql.DB, number int)

func (*Agents) Get

func (agents *Agents) Get(db *sql.DB, filterQuery string) error

func (*Agents) GetAuthorizedAndShowFacts

func (agents *Agents) GetAuthorizedAndShowFacts(db *sql.DB, filterQuery string, authorization *auth.Authorization, showFacts []string, pag *pagination.Pagination) error

type Db

type Db interface {
	QueryRow(query string, args ...interface{}) *sql.Row
	Exec(query string, args ...interface{}) (sql.Result, error)
}

type FilterError

type FilterError struct {
	Msg string
}

func (FilterError) Error

func (e FilterError) Error() string

type JSONB

type JSONB map[string]interface{}

func JSONBfromString

func JSONBfromString(data string) (*JSONB, error)

func JobUserToJSONB

func JobUserToJSONB(user auth.User) (*JSONB, error)

func (*JSONB) Scan

func (j *JSONB) Scan(value interface{}) error

func (JSONB) Value

func (j JSONB) Value() (interface{}, error)

type Job

type Job struct {
	arc.Request
	Status    arc.JobState `json:"status"`
	CreatedAt time.Time    `json:"created_at"`
	UpdatedAt time.Time    `json:"updated_at"`
	Project   string       `json:"project"`
	User      JSONB        `json:"user"`
}

func CreateJob

func CreateJob(db *sql.DB, data *[]byte, identity string, user *auth.User) (*Job, error)

func CreateJobAuthorized

func CreateJobAuthorized(db *sql.DB, data *[]byte, identity string, authorization *auth.Authorization) (*Job, error)

func (*Job) CustomExecuteScriptExample

func (job *Job) CustomExecuteScriptExample(status arc.JobState, createdAt time.Time, timeout int)

func (*Job) ExecuteScriptExample

func (job *Job) ExecuteScriptExample()

func (*Job) Get

func (job *Job) Get(db *sql.DB) error

func (*Job) GetAuthorized

func (job *Job) GetAuthorized(db *sql.DB, authorization *auth.Authorization) error

func (*Job) RpcVersionExample

func (job *Job) RpcVersionExample()

func (*Job) Save

func (job *Job) Save(db *sql.DB) error

func (*Job) Update

func (job *Job) Update(db *sql.DB) (err error)

type JobBadRequestError

type JobBadRequestError struct {
	Msg string
}

func (JobBadRequestError) Error

func (e JobBadRequestError) Error() string

type JobID

type JobID struct {
	RequestID string `json:"request_id"`
}

type JobTargetAgentNotFoundError

type JobTargetAgentNotFoundError struct {
	Msg string
}

func (JobTargetAgentNotFoundError) Error

type Jobs

type Jobs []Job

func (*Jobs) CreateAndSaveRpcVersionExamples

func (jobs *Jobs) CreateAndSaveRpcVersionExamples(db *sql.DB, number int)

func (*Jobs) Get

func (jobs *Jobs) Get(db *sql.DB) error

func (*Jobs) GetAuthorized

func (jobs *Jobs) GetAuthorized(db *sql.DB, authorization *auth.Authorization, agentId string, pag *pagination.Pagination) error

type Lock

type Lock struct {
	LockID    string    `json:"registry_id"`
	AgentID   string    `json:"agent_id"`
	CreatedAt time.Time `json:"created_at"`
}

func (*Lock) Example

func (l *Lock) Example()

func (*Lock) Get

func (l *Lock) Get(db Db) error

func (*Lock) Save

func (l *Lock) Save(db Db) error

type Log

type Log struct {
	JobID     string    `json:"job_id"`
	Content   string    `json:"content"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (*Log) Get

func (log *Log) Get(db *sql.DB) error

func (*Log) GetOrCollect

func (log *Log) GetOrCollect(db *sql.DB) error

func (*Log) GetOrCollectAuthorized

func (log *Log) GetOrCollectAuthorized(db *sql.DB, authorization *auth.Authorization) error

func (*Log) Save

func (log *Log) Save(db *sql.DB) error

type LogPart

type LogPart struct {
	JobID     string    `json:"job_id"`
	Number    uint      `json:"number"`
	Content   string    `json:"content"`
	Final     bool      `json:"final"`
	CreatedAt time.Time `json:"created_at"`
}

func (*LogPart) Collect

func (log_part *LogPart) Collect(db *sql.DB) (*string, error)

func (*LogPart) Get

func (log_part *LogPart) Get(db *sql.DB) error

func (*LogPart) Save

func (log_part *LogPart) Save(db *sql.DB) error

func (*LogPart) SaveLogPartExamples

func (logpart *LogPart) SaveLogPartExamples(db *sql.DB, id string) string

type Registration

type Registration struct {
	arc.Registration
}

func (*Registration) Example

func (reg *Registration) Example()

type RegistrationExistsError

type RegistrationExistsError struct {
	Msg string
}

func (RegistrationExistsError) Error

func (e RegistrationExistsError) Error() string

type Reply

type Reply struct {
	arc.Reply
}

func (*Reply) ExecuteScriptExample

func (reply *Reply) ExecuteScriptExample(id string, final bool, payload string, number uint)

type ReplyExistsError

type ReplyExistsError struct {
	Msg string
}

func (ReplyExistsError) Error

func (e ReplyExistsError) Error() string

type Request

type Request struct {
	arc.Request
}

func (*Request) Example

func (req *Request) Example()

type Status

type Status string

type TagError

type TagError struct {
	Messages map[string][]string
}

func (*TagError) Error

func (e *TagError) Error() string

func (*TagError) MessagesToJson

func (e *TagError) MessagesToJson() (string, error)

Jump to

Keyboard shortcuts

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