payload

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseJobStatus added in v0.5.0

func ParseJobStatus(jobStatus JobStatusEnum) (status string)

func ParsePayloadRequest added in v0.5.0

func ParsePayloadRequest(payloadReq PayloadRequestEnum) (status string)

ParsePayloadRequest return humanize value of PayloadRequestEnum

Types

type JobDetailMetadata

type JobDetailMetadata struct {
	// ID is the unique identifier for the job.
	ID string `json:"id"`

	// JobName is the name given to the job.
	JobName string `json:"job_name"`

	// Command specifies the command-line arguments used to execute the job. Required for creating new job.
	Command []string `json:"command,omitempty"`

	// Metadata contains additional regular payload metadata associated with the job.
	Metadata PayloadRegularMetadata `json:"metadata,omitempty"`

	// CreatedAt indicates when the job was recorded first time.
	CreatedAt time.Time `json:"created_at"`

	// UpdatedAt indicates every single changes job status.
	UpdatedAt time.Time `json:"updated_at"`

	// MetadataFilter allows filtering jobs based on their metadata.
	// It's a map where keys are metadata field names and values are the desired values.
	MetadataFilter map[string]string `json:"metadata_filter,omitempty"`
}

JobDetailMetadata provides detailed information about a specific job.

This struct can be used to create Job with REQUEST_EXECUTE_JOB payload request.

type JobErrorResponse added in v0.3.0

type JobErrorResponse struct {
	Error string `json:"error"`
}

JobError is used to unmarshal error messages from a JSON response payload. It expects a JSON object with a single "error" key containing the error message.

type JobPayload

type JobPayload struct {
	// Request specifies the type of operation to be performed (e.g., execute, list, status).
	Request PayloadRequestEnum `json:"request"`

	// Timestamp records the time when the request was initiated or last updated.
	Timestamp time.Time `json:"timestamp"`

	// Metadata holds additional, request-specific data. Its structure varies based on the 'Request' type.
	Metadata PayloadRegularMetadata `json:"metadata,omitempty"`
}

JobPayload represents the standard structure for job-related requests.

It encapsulates the type of request, a timestamp, and generic metadata.

func (*JobPayload) MarshalMetadata

func (j *JobPayload) MarshalMetadata(target any) error

MarshalMetadata marshals a given Go struct or type into the generic 'Metadata' field of the JobPayload. It converts the structured data into an `any` type suitable for the `Metadata` field, typically as a `map[string]any`.

func (*JobPayload) UnmarshalMetadata

func (j *JobPayload) UnmarshalMetadata(target any) error

UnmarshalMetadata unmarshals the generic 'Metadata' field of the JobPayload into a target Go struct or type. It allows strong-typing of the metadata content.

type JobResponse

type JobResponse struct {
	// Status indicates the current status of the job.
	Status JobStatusEnum `json:"status"`

	// ExitCode provides the exit code of the job process.
	ExitCode int `json:"exitcode"`

	// JobDetailMetadata embeds additional metadata about the job.
	JobDetailMetadata
}

JobResponse represents the detailed response for a job query.

It includes the job's status, exit code, and additional job details.

type JobResponseCount

type JobResponseCount struct {

	// Count is the total number of jobs matching the criteria.
	Count int `json:"count"`
}

JobResponseCount represents a response containing only the count of jobs.

type JobSearchMetadata

type JobSearchMetadata struct {
	// RequestMeta indicates whether metadata related to the request should be included.
	RequestMeta bool `json:"request_meta,omitempty"`

	// Search specifies the search query string.
	Search string `json:"search,omitempty"`

	// ActiveOnly filters results to include only active jobs.
	// Cannot be combined with FinishOnly.
	ActiveOnly bool `json:"active_only,omitempty"`

	// FinishOnly filters results to include only finished jobs whether job is success or failed.
	// Cannot be combined with ActiveOnly.
	FinishOnly bool `json:"finish_only,omitempty"`

	// Page specifies the page number for pagination. When set,
	// the Limit field will be used to determine the maximum number of results per page.
	Page int `json:"page,omitempty"`

	// Limit sets the overall maximum number of results to return.
	// When pagination is enabled via the Page field, it determines the maximum number of results per page.
	Limit int `json:"limit,omitempty"`

	// When true, indicates that only the count of matching jobs should be returned.
	NumberOnly bool `json:"number_only,omitempty"`

	// When true, orders the results in descending order.
	OrderDesc bool `json:"desc,omitempty"`

	// MetadataFilter allows filtering jobs based on their metadata.
	// It's a map where keys are metadata field names and values are the desired values.
	MetadataFilter map[string]string `json:"metadata_filter,omitempty"`

	// Follow indicates whether to stream new log lines in real-time (similar to command tail -f).
	Follow bool `json:"follow,omitempty"`

	// HideCommand prevents the command from being exposed in the job response.
	HideCommand bool `json:"hide_command,omitempty"`
}

JobSearchMetadata defines the structure for search criteria used to query job information.

The result of a JobSearchMetadata query typically yields a JobResponse.

If NumberOnly is set to true, the query will instead return a JobResponseCount.

type JobStatusEnum

type JobStatusEnum int32

JobStatusEnum represents the status of a job.

const (
	// JOB_RUNNING indicates that the job is currently running.
	JOB_RUNNING JobStatusEnum = 1 << iota
	// JOB_FINISH indicates that the job has completed successfully.
	JOB_FINISH
	// JOB_FAILED indicates that the job has failed.
	JOB_FAILED
	// JOB_NOT_RUNNING indicates that the job is not currently running.
	JOB_NOT_RUNNING
	// JOB_STOPPED indicates that the job is stopped.
	JOB_STOPPED
)

type PayloadRegularMetadata

type PayloadRegularMetadata any

PayloadRegularMetadata is a type alias for any, used to hold arbitrary metadata associated with a job request. This allows for flexible and extensible payload structures.

type PayloadRequestEnum

type PayloadRequestEnum int32

PayloadRequestEnum defines the type of request being made in a job payload.

const (
	// REQUEST_EXECUTE_JOB indicates a request to execute a new job. Return of this request is void.
	REQUEST_EXECUTE_JOB PayloadRequestEnum = 1 << iota
	// REQUEST_LIST indicates a request to list existing jobs. Return of this request is []JobResponse.
	REQUEST_LIST
	// REQUEST_WAIT indicates a request to wait for a job to complete. Return of this request is JobResponse.
	REQUEST_WAIT
	// REQUEST_STATUS indicates a request to get the status of a specific job. Return of this request is JobResponse.
	REQUEST_STATUS
	// REQUEST_VIBE_CHECK indicates a request to perform a health or liveness check. Return of this request is void.
	REQUEST_VIBE_CHECK
	// REQUEST_STOP indicates a request to stop a job.
	// If the job exist, the return is JobResponse. If the job not exist, the return is an empty JobResponse.
	REQUEST_STOP
	// REQUEST_TAIL_LOG indicates a request to tail/stream a job's log file in real-time.
	// Returns streaming log lines until connection is closed or job completes.
	REQUEST_TAIL_LOG
)

Jump to

Keyboard shortcuts

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