daemon

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DaemonError

type DaemonError struct {
	Message     string
	ParentError error
}

func (*DaemonError) Error

func (d *DaemonError) Error() string

type DaemonPayloadError

type DaemonPayloadError struct {
	Message     string
	JobID       string
	ParentError error
}

func (*DaemonPayloadError) Error

func (d *DaemonPayloadError) Error() string

func (*DaemonPayloadError) Warning

func (d *DaemonPayloadError) Warning()

type DaemonStruct

type DaemonStruct struct {
	SocketListener net.Listener
	DB             *sqlx.DB
	config.BobbitDaemonConfig
}

DaemonStruct holds the main components of the Bobbit daemon, including its socket listener and configuration.

func CreateDaemon

func CreateDaemon(c config.BobbitDaemonConfig) (*DaemonStruct, error)

CreateDaemon initializes and starts the daemon. It checks for existing daemon instances, creates necessary data directories, and sets up the Unix socket listener. It returns a pointer to a DaemonStruct or an error if initialization fails.

func (*DaemonStruct) CleanupDaemon

func (d *DaemonStruct) CleanupDaemon(sigChan <-chan os.Signal)

CleanupDaemon listens for an OS signal and performs cleanup operations before exiting. It removes the daemon's socket file.

func (*DaemonStruct) HandleJob

func (d *DaemonStruct) HandleJob(jc *JobContext) error

HandleJob processes a new job request. It validates the job payload, generates a unique ID if not provided, creates necessary data files (lock, log, metadata), executes the command, captures its output and exit code, and cleans up the lock file.

func (*DaemonStruct) HandleTailJobLog added in v0.5.0

func (d *DaemonStruct) HandleTailJobLog(jc *JobContext) error

HandleTailJobLog handles requests to tail/stream a job's log file in real-time. It finds the job, locates its log file, and streams log lines to the client until the connection is closed or the job completes.

func (*DaemonStruct) HandleVibeCheck

func (d *DaemonStruct) HandleVibeCheck(jc *JobContext) error

HandleVibeCheck handles a "vibe check" request, which typically serves as a basic ping to confirm the daemon is responsive. It unmarshals the request metadata.

func (*DaemonStruct) ListJob

func (d *DaemonStruct) ListJob(jc *JobContext) error

ListJob handles requests to list jobs. It reads job data from the configured directory, filters them based on `JobSearchMetadata` criteria (e.g., active only, limit), parses their status and optional metadata, sorts them, and sends the results back to the client.

Check payload.JobSearchMetadata for more information.

func (*DaemonStruct) NewJobContext

func (d *DaemonStruct) NewJobContext(conn net.Conn) *JobContext

NewJobContext creates and returns a new JobContext for a given network connection. This context is used to manage a single job request.

func (*DaemonStruct) StatusJob

func (d *DaemonStruct) StatusJob(jc *JobContext) error

StatusJob handles requests to retrieve the current status of a specific job. It finds the job based on the provided search metadata, parses its exit code to determine its status, and sends the `JobResponse` back to the client.

func (*DaemonStruct) StopJob added in v0.3.0

func (d *DaemonStruct) StopJob(jc *JobContext) error

StopJob handles requests to stop the specific job. If the job exist, the return is JobResponse. If the job not exist, the return is an empty JobResponse.

func (*DaemonStruct) WaitJob

func (d *DaemonStruct) WaitJob(jc *JobContext) error

WaitJob handles requests to wait for a specific job to complete. It continuously checks for the absence of the job's lock file and responds to the client with the job's final status once completed. It also handles client connection timeouts.

type HandlerFunc added in v0.5.0

type HandlerFunc func(jc *JobContext) error

type JobContext

type JobContext struct {
	Payload payload.JobPayload
	// contains filtered or unexported fields
}

JobContext holds the context for a single job request handled by the daemon, including the network connection and the job payload.

func (*JobContext) Close

func (jc *JobContext) Close()

Close closes the network connection associated with the JobContext.

func (*JobContext) GetPayload

func (jc *JobContext) GetPayload() error

GetPayload reads and decodes a JobPayload from the JobContext's network connection. It populates the Payload field of the JobContext and returns an error if decoding fails. If the payload's timestamp is zero, it defaults to the current time.

func (*JobContext) SendPayload

func (jc *JobContext) SendPayload(target any) error

SendPayload encodes and sends the given target object over the JobContext's network connection. It returns an error if encoding or writing fails.

Jump to

Keyboard shortcuts

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