tasklog

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package tasklog implements ppacer Task loggers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory interface {
	GetLogger(TaskInfo) *slog.Logger
	GetLogReader(TaskInfo) Reader
}

Factory represents an object which can create loggers and log readers for given DAG run tasks. Usually there should be at least one implementation of this interface for supported by ppacer persistence layer (like SQLite, PostgreSQL, etc).

type Reader

type Reader interface {
	ReadAll(context.Context) ([]Record, error)
	ReadLatest(context.Context, int) ([]Record, error)
}

Reader represents a reader for single dag.Task log records. TODO(dskrzypiec): this interface will be revised after frontend implementation for fetching task logs.

type Record

type Record struct {
	Level      string
	InsertTs   time.Time
	Message    string
	Attributes map[string]any
}

Record represents single dag.Task log record. It doesn't contain information about DAG run task, because Reader is instantiated for given TaskInfo.

type SQLite

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

SQLite implements Factory using SQLite database as a target for task logs.

func NewSQLite

func NewSQLite(dbClient *db.LogsClient, loggerOpts *slog.HandlerOptions) *SQLite

NewSQLite instantiate new SQLite object. Given database client should be setup to use SQLite. Optionally provided loggerOpts would be used in the logger for task logs.

func (*SQLite) GetLogReader

func (s *SQLite) GetLogReader(ti TaskInfo) Reader

GetLogReader returns an instance of Reader for reading log records related to given DAG run task.

func (*SQLite) GetLogger

func (s *SQLite) GetLogger(ti TaskInfo) *slog.Logger

GetLogger returns new instance of slog.Logger dedicated to log events related to given DAG run task. Logs are stored in SQLite database configured in NewSQLite.

type TaskInfo

type TaskInfo struct {
	DagId  string
	ExecTs time.Time
	TaskId string
	Retry  int
}

TaskInfo contains information about task context including DAG run information.

Jump to

Keyboard shortcuts

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