task_logs

package
v0.0.0-...-dfed899 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeBroadcaster

type ChangeBroadcaster interface {
	// BroadcastTaskLogUpdate sends the task log update to SocketIO clients.
	BroadcastTaskLogUpdate(taskLogUpdate api.EventTaskLogUpdate)
}

type LocalStorage

type LocalStorage interface {
	// ForJob returns the absolute directory path for storing job-related files.
	ForJob(jobUUID string) string
}

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage can write data to task logs, rotate logs, etc.

func NewStorage

func NewStorage(
	localStorage LocalStorage,
	clock clock.Clock,
	broadcaster ChangeBroadcaster,
) *Storage

NewStorage creates a new log storage rooted at `basePath`.

func (*Storage) Filepath

func (s *Storage) Filepath(jobID, taskID string) string

Filepath returns the file path suitable to write a log file. Note that this intentionally shares the behaviour of `pathForJob()` in `internal/manager/local_storage/local_storage.go`; it is intended that the file handling code in this source file is migrated to use the `local_storage` package at some point.

func (*Storage) RotateFile

func (s *Storage) RotateFile(logger zerolog.Logger, jobID, taskID string)

RotateFile rotates the task's log file, ignoring (but logging) any errors that occur.

func (*Storage) Tail

func (s *Storage) Tail(jobID, taskID string) (string, error)

Tail reads the final few lines of a task log.

func (*Storage) TaskLogSize

func (s *Storage) TaskLogSize(jobID, taskID string) (int64, error)

TaskLogSize returns the size of the task log, in bytes.

func (*Storage) Write

func (s *Storage) Write(logger zerolog.Logger, jobID, taskID string, logText string) error

Write appends text to a task's log file, and broadcasts the log lines via SocketIO.

func (*Storage) WriteTimestamped

func (s *Storage) WriteTimestamped(logger zerolog.Logger, jobID, taskID string, logText string) error

Write appends text, prefixed with the current date & time, to a task's log file, and broadcasts the log lines via SocketIO.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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