model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AMQPJob

type AMQPJob struct {
	Connection   string                 `json:"connection"`    // e.g., "amqp://guest:guest@localhost:5672/"
	Exchange     string                 `json:"exchange"`      // e.g., "my_exchange"
	RoutingKey   string                 `json:"routing_key"`   // e.g., "my_routing_key"
	Headers      map[string]interface{} `json:"headers"`       // e.g., {"x-delay": 10000}
	Body         string                 `json:"body"`          // e.g., "Hello, world!"
	BodyEncoding *BodyEncoding          `json:"body_encoding"` // e.g., null, "base64"
	ContentType  string                 `json:"content_type"`  // e.g., "text/plain"
}

func (*AMQPJob) RemoveCredentials

func (amqpJob *AMQPJob) RemoveCredentials()

RemoveCredentials removes the credentials from the AMQPJob struct.

func (*AMQPJob) Validate

func (amqpJob *AMQPJob) Validate() error

Validate validates an AMQPJob struct.

type Auth

type Auth struct {
	Type        AuthType    `json:"type"`                                        // e.g., "none", "basic", "bearer"
	Username    null.String `json:"username,omitempty" swaggertype:"string"`     // for "basic"
	Password    null.String `json:"password,omitempty" swaggertype:"string"`     // for "basic"
	BearerToken null.String `json:"bearer_token,omitempty" swaggertype:"string"` // for "bearer"
}

func (*Auth) Validate

func (auth *Auth) Validate() error

type AuthType

type AuthType string
const (
	AuthTypeNone   AuthType = "none"
	AuthTypeBasic  AuthType = "basic"
	AuthTypeBearer AuthType = "bearer"
)

func (AuthType) Valid

func (at AuthType) Valid() bool

type BodyEncoding

type BodyEncoding string
const (
	BodyEncodingBase64 BodyEncoding = "base64"
)

func (*BodyEncoding) Valid

func (be *BodyEncoding) Valid() bool

type HTTPJob

type HTTPJob struct {
	URL                string            `json:"url"`                       // e.g., "https://example.com"
	Method             string            `json:"method"`                    // e.g., "GET", "POST", "PUT", "PATCH", "DELETE"
	Headers            map[string]string `json:"headers"`                   // e.g., {"Content-Type": "application/json"}
	Body               null.String       `json:"body" swaggertype:"string"` // e.g., "{\"hello\": \"world\"}"
	ValidResponseCodes []int             `json:"valid_response_codes"`      // e.g., [200, 201, 202]
	Auth               Auth              `json:"auth"`                      // e.g., {"type": "basic", "username": "foo", "password": "bar"}
}

func (*HTTPJob) RemoveCredentials

func (httpJob *HTTPJob) RemoveCredentials()

func (*HTTPJob) Validate

func (httpJob *HTTPJob) Validate() error

Validate validates an HTTPJob struct.

type Job

type Job struct {
	ID     uuid.UUID `json:"id"`
	Type   JobType   `json:"type"`
	Status JobStatus `json:"status"`

	ExecuteAt    null.Time   `json:"execute_at" swaggertype:"string"`    // for one-off jobs
	CronSchedule null.String `json:"cron_schedule" swaggertype:"string"` // for recurring jobs

	HTTPJob *HTTPJob `json:"http_job,omitempty"`

	AMQPJob *AMQPJob `json:"amqp_job,omitempty"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	// when the job is scheduled to run next (can be null if the job is not scheduled to run again)
	NextRun           null.Time `json:"next_run,omitempty"`
	NumberOfRuns      *int      `json:"num_runs,omitempty"`
	AllowedFailedRuns *int      `json:"allowed_failed_runs,omitempty"`

	// Custom user tags that can be used to filter jobs
	Tags []string `json:"tags"`
}

swagger:model Job

func (*Job) ApplyUpdate

func (j *Job) ApplyUpdate(update JobUpdate)

func (*Job) RemoveCredentials

func (j *Job) RemoveCredentials()

RemoveCredentials removes sensitive information from the job, when returning it to the user.

func (*Job) SetInitialRunTime

func (j *Job) SetInitialRunTime()

func (*Job) SetNextRunTime

func (j *Job) SetNextRunTime()

func (*Job) Validate

func (j *Job) Validate() error

Validate validates a Job struct.

type JobCreate

type JobCreate struct {

	// Job type
	Type JobType `json:"type"`

	// ExecuteAt and CronSchedule are mutually exclusive.
	ExecuteAt    null.Time   `json:"execute_at" swaggertype:"string"`    // for one-off jobs
	CronSchedule null.String `json:"cron_schedule" swaggertype:"string"` // for recurring jobs

	// HTTPJob and AMQPJob are mutually exclusive.
	HTTPJob *HTTPJob `json:"http_job,omitempty"`
	AMQPJob *AMQPJob `json:"amqp_job,omitempty"`

	Tags []string `json:"tags"`
}

func (*JobCreate) ToJob

func (j *JobCreate) ToJob() *Job

type JobExecution

type JobExecution struct {
	ID                 int         `json:"id"`
	JobID              uuid.UUID   `json:"job_id"`
	StartTime          time.Time   `json:"start_time"`
	EndTime            time.Time   `json:"end_time"`
	Success            bool        `json:"success"`
	NumberOfExecutions int         `json:"number_of_executions"`
	NumberOfRetries    int         `json:"number_of_retries"`
	ErrorMessage       null.String `json:"error_message,omitempty" swaggertype:"string"`
}

type JobExecutionStatus

type JobExecutionStatus string
const (
	JobExecutionStatusSuccessful JobExecutionStatus = "SUCCESSFUL"
	JobExecutionStatusFailed     JobExecutionStatus = "FAILED"
)

type JobStatus

type JobStatus string
const (
	JobStatusRunning               JobStatus = "RUNNING"
	JobStatusScheduled             JobStatus = "SCHEDULED"
	JobStatusCancelled             JobStatus = "CANCELLED"
	JobStatusExecuted              JobStatus = "EXECUTED"
	JobStatusCompleted             JobStatus = "COMPLETED"
	JobStatusAwaitingNextExecution JobStatus = "AWAITING_NEXT_EXECUTION"
	JobStatusStopped               JobStatus = "STOPPED"
)

func (JobStatus) Valid

func (js JobStatus) Valid() bool

type JobType

type JobType string
const (
	JobTypeHTTP JobType = "HTTP"
	JobTypeAMQP JobType = "AMQP"
)

JobType is the type of job. Currently, only HTTP and AMQP jobs are supported.

func (JobType) Valid

func (jt JobType) Valid() bool

type JobUpdate

type JobUpdate struct {
	Type *JobType `json:"type,omitempty"`
	HTTP *HTTPJob `json:"http,omitempty"`
	AMQP *AMQPJob `json:"amqp,omitempty"`

	CronSchedule *string    `json:"cron_schedule,omitempty"`
	ExecuteAt    *time.Time `json:"execute_at,omitempty"`

	Tags *[]string `json:"tags,omitempty"`
}

swagger:model JobUpdate

Jump to

Keyboard shortcuts

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