logs

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package logs handles log output from a run

Index

Constants

View Source
const (
	STX = 0x02 // marks the beginning of logs for a phase
	ETX = 0x03 // marks the end of logs for a phase
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunk added in v0.3.6

type Chunk struct {
	resource.ID `json:"id"` // Uniquely identifies the chunk.

	RunID  resource.ID        `json:"run_id"` // ID of run that generated the chunk
	Phase  internal.PhaseType `json:"phase"`  // Phase that generated the chunk
	Offset int                `json:"offset"` // Position within logs.
	Data   []byte             `json:"data"`   // The log data
}

Chunk is a section of logs for a phase.

func (Chunk) Cut added in v0.3.6

func (c Chunk) Cut(opts GetChunkOptions) Chunk

Cut returns a new, smaller chunk.

func (Chunk) IsEnd added in v0.3.6

func (c Chunk) IsEnd() bool

func (Chunk) IsStart added in v0.3.6

func (c Chunk) IsStart() bool

func (Chunk) NextOffset added in v0.3.6

func (c Chunk) NextOffset() int

NextOffset returns the offset for the next chunk

func (Chunk) ToHTML added in v0.3.6

func (c Chunk) ToHTML() template.HTML

type Client

type Client struct {
	*otfapi.Client
}

func (*Client) PutChunk

func (c *Client) PutChunk(ctx context.Context, opts PutChunkOptions) error

type GetChunkOptions added in v0.3.6

type GetChunkOptions struct {
	RunID  resource.ID        `schema:"run_id"`
	Phase  internal.PhaseType `schema:"phase"`
	Limit  int                `schema:"limit"`  // size of the chunk to retrieve
	Offset int                `schema:"offset"` // position in overall data to seek from.
}

type Options

type Options struct {
	logr.Logger
	internal.Cache
	*sql.DB
	*sql.Listener
	internal.Verifier

	Authorizer *authz.Authorizer
}

type PhaseWriter

type PhaseWriter struct {
	PutChunkService // for uploading logs to server
	// contains filtered or unexported fields
}

PhaseWriter writes logs on behalf of a run phase.

func NewPhaseWriter

func NewPhaseWriter(ctx context.Context, opts PhaseWriterOptions) *PhaseWriter

func (*PhaseWriter) Close

func (w *PhaseWriter) Close() error

Close must be called to complete writing job logs

func (*PhaseWriter) Write

func (w *PhaseWriter) Write(p []byte) (int, error)

Write uploads a chunk of logs to the server.

type PhaseWriterOptions

type PhaseWriterOptions struct {
	RunID  resource.ID
	Phase  internal.PhaseType
	Writer PutChunkService
}

type PutChunkOptions added in v0.3.6

type PutChunkOptions struct {
	RunID  resource.ID        `schema:"run_id,required"`
	Phase  internal.PhaseType `schema:"phase,required"`
	Offset int                `schema:"offset,required"`
	Data   []byte
}

type PutChunkService added in v0.3.6

type PutChunkService interface {
	PutChunk(ctx context.Context, opts PutChunkOptions) error
}

type Service

type Service struct {
	logr.Logger
	authz.Interface
	// contains filtered or unexported fields
}

func NewService

func NewService(opts Options) *Service

func (*Service) AddHandlers added in v0.2.2

func (s *Service) AddHandlers(r *mux.Router)

func (*Service) GetChunk

func (s *Service) GetChunk(ctx context.Context, opts GetChunkOptions) (Chunk, error)

GetChunk reads a chunk of logs for a phase.

NOTE: unauthenticated - access granted only via signed URL

func (*Service) PutChunk added in v0.2.2

func (s *Service) PutChunk(ctx context.Context, opts PutChunkOptions) error

PutChunk writes a chunk of logs for a phase

func (*Service) Tail

func (s *Service) Tail(ctx context.Context, opts GetChunkOptions) (<-chan Chunk, error)

Tail logs for a phase. Offset specifies the number of bytes into the logs from which to start tailing.

func (*Service) WatchLogs added in v0.2.0

func (s *Service) WatchLogs(ctx context.Context) (<-chan pubsub.Event[Chunk], func())

Jump to

Keyboard shortcuts

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