output

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package output provides functionality for reading SLURM job output files. It supports both local filesystem access and remote file retrieval via SSH, with efficient handling of large files through streaming and pagination.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCacheKey

func GenerateCacheKey(jobID, outputType string) string

GenerateCacheKey generates a cache key for job output

Types

type CacheEntry

type CacheEntry struct {
	Content   *OutputContent
	Timestamp time.Time
	TTL       time.Duration
}

CacheEntry represents a cached output result

func (*CacheEntry) IsExpired

func (ce *CacheEntry) IsExpired() bool

IsExpired checks if the cache entry has expired

type CacheStats

type CacheStats struct {
	Entries   int
	Hits      int64
	Misses    int64
	Evictions int64
	HitRate   float64
	MaxSize   int
}

CacheStats contains cache statistics

type FileMetadata

type FileMetadata struct {
	Path        string
	Size        int64
	ModTime     time.Time
	Exists      bool
	IsLocal     bool
	NodeID      string
	Permissions os.FileMode
	Encoding    string
}

FileMetadata contains file information

type JobOutputReader

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

JobOutputReader orchestrates reading job output files

func NewJobOutputReader

func NewJobOutputReader(pathResolver PathResolver, sshClient SSHExecutor) *JobOutputReader

NewJobOutputReader creates a new job output reader

func (*JobOutputReader) ClearCache

func (r *JobOutputReader) ClearCache()

ClearCache clears the output cache

func (*JobOutputReader) GetMetadata

func (r *JobOutputReader) GetMetadata(ctx context.Context, jobID, outputType string) (*FileMetadata, error)

GetMetadata returns file metadata without reading content

func (*JobOutputReader) ReadJobOutput

func (r *JobOutputReader) ReadJobOutput(ctx context.Context, jobID, outputType string) (*OutputContent, error)

ReadJobOutput reads complete job output

func (*JobOutputReader) ReadPartial

func (r *JobOutputReader) ReadPartial(ctx context.Context, jobID, outputType string, opts ReadOptions) (*OutputContent, error)

ReadPartial reads output with options

func (*JobOutputReader) SetCache

func (r *JobOutputReader) SetCache(cache *OutputCache)

SetCache sets a custom cache (useful for testing or custom cache configurations)

type LocalFileReader

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

LocalFileReader handles reading files from the local filesystem

func NewLocalFileReader

func NewLocalFileReader() *LocalFileReader

NewLocalFileReader creates a new local file reader

func (*LocalFileReader) GetFileInfo

func (r *LocalFileReader) GetFileInfo(path string) (*FileMetadata, error)

GetFileInfo returns file metadata

func (*LocalFileReader) HeadFile

func (r *LocalFileReader) HeadFile(ctx context.Context, path string, lines int) (string, error)

HeadFile reads first N lines

func (*LocalFileReader) ReadFile

func (r *LocalFileReader) ReadFile(ctx context.Context, path string) (string, error)

ReadFile reads a complete local file

func (*LocalFileReader) ReadRange

func (r *LocalFileReader) ReadRange(ctx context.Context, path string, offset, length int64) (string, error)

ReadRange reads specific byte range

func (*LocalFileReader) TailFile

func (r *LocalFileReader) TailFile(ctx context.Context, path string, lines int) (string, error)

TailFile reads last N lines efficiently

type OutputCache

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

OutputCache provides LRU caching for job output

func NewOutputCache

func NewOutputCache(defaultTTL time.Duration, maxSize int) *OutputCache

NewOutputCache creates a new output cache

func (*OutputCache) CleanupExpired

func (c *OutputCache) CleanupExpired() int

CleanupExpired removes expired entries

func (*OutputCache) Clear

func (c *OutputCache) Clear()

Clear removes all entries from the cache

func (*OutputCache) Delete

func (c *OutputCache) Delete(key string)

Delete removes an entry from the cache

func (*OutputCache) Get

func (c *OutputCache) Get(key string) (*OutputContent, bool)

Get retrieves an output from the cache

func (*OutputCache) Set

func (c *OutputCache) Set(key string, content *OutputContent, ttl time.Duration)

Set stores an output in the cache

func (*OutputCache) Stats

func (c *OutputCache) Stats() CacheStats

Stats returns cache statistics

type OutputContent

type OutputContent struct {
	Content     string
	Metadata    *FileMetadata
	Truncated   bool
	TruncatedAt int64
	LinesRead   int
	BytesRead   int64
	Source      string // "local" or "remote:node042"
}

OutputContent represents read output

type PathResolver

type PathResolver interface {
	ResolveOutputPath(jobID, outputType string) (path string, isRemote bool, nodeID string, err error)
}

PathResolver defines the interface for resolving job output paths

type ReadOptions

type ReadOptions struct {
	MaxBytes     int64         // Maximum bytes to read (0 = unlimited)
	MaxLines     int           // Maximum lines to read (0 = unlimited)
	TailMode     bool          // Read from end instead of beginning
	Offset       int64         // Byte offset to start reading
	Timeout      time.Duration // Timeout for remote operations
	CacheEnabled bool          // Enable local caching
	ForceRefresh bool          // Bypass cache
}

ReadOptions configures how output is read

func DefaultReadOptions

func DefaultReadOptions() ReadOptions

DefaultReadOptions returns sensible defaults for read operations

type Reader

type Reader interface {
	// ReadJobOutput reads complete job output
	ReadJobOutput(ctx context.Context, jobID, outputType string) (*OutputContent, error)

	// ReadPartial reads output with options
	ReadPartial(ctx context.Context, jobID, outputType string, opts ReadOptions) (*OutputContent, error)

	// GetMetadata returns file metadata without reading content
	GetMetadata(ctx context.Context, jobID, outputType string) (*FileMetadata, error)
}

Reader interface for job output

type RemoteFileReader

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

RemoteFileReader handles reading files via SSH

func NewRemoteFileReader

func NewRemoteFileReader(sshClient SSHExecutor) *RemoteFileReader

NewRemoteFileReader creates a new remote file reader

func (*RemoteFileReader) GetRemoteFileInfo

func (r *RemoteFileReader) GetRemoteFileInfo(ctx context.Context, nodeID, path string) (*FileMetadata, error)

GetRemoteFileInfo returns metadata about a remote file

func (*RemoteFileReader) HasSSHClient added in v0.6.0

func (r *RemoteFileReader) HasSSHClient() bool

HasSSHClient returns true if an SSH client is configured

func (*RemoteFileReader) HeadRemoteFile

func (r *RemoteFileReader) HeadRemoteFile(ctx context.Context, nodeID, path string, lines int) (string, error)

HeadRemoteFile reads first N lines via SSH head

func (*RemoteFileReader) ReadRemoteFile

func (r *RemoteFileReader) ReadRemoteFile(ctx context.Context, nodeID, path string) (string, error)

ReadRemoteFile reads file via SSH cat command

func (*RemoteFileReader) TailRemoteFile

func (r *RemoteFileReader) TailRemoteFile(ctx context.Context, nodeID, path string, lines int) (string, error)

TailRemoteFile reads last N lines via SSH tail

type SSHExecutor

type SSHExecutor interface {
	ExecuteCommand(ctx context.Context, hostname, command string) (string, error)
}

SSHExecutor defines the interface for SSH command execution

Jump to

Keyboard shortcuts

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