payload

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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"`

	// Timestamp indicates when the job was recorded or last updated.
	Timestamp time.Time `json:"timestamp"`

	// 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"`
}

JobDetailMetadata provides detailed information about a specific job.

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

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.
	ActiveOnly bool `json:"active_only,omitempty"`

	// Limit sets the maximum number of results to return.
	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"`
}

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
)

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
)

Jump to

Keyboard shortcuts

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