storage

package
v0.0.0-...-34e89b1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DB

func DB(ctx context.Context) (*sqlx.DB, error)

DB will return the sqlx.DB in use for the user module. This enables reuse of the storage package from outside the app without exposing implementation detail.

func Migrate

func Migrate(ctx context.Context, db *sqlx.DB, schema fs.FS) error

Migrate applies SQL migrations from the given filesystem to the database.

Types

type JSONBuffer

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

JSONBuffer is a byte buffer

func NewJSONBuffer

func NewJSONBuffer() *JSONBuffer

NewJSONBuffer creates a new JSONBuffer

func (*JSONBuffer) String

func (j *JSONBuffer) String() string

func (*JSONBuffer) Write

func (j *JSONBuffer) Write(b []byte) (int, error)

Write writes a new line

type Log

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

Log provides methods for easy logging. This should be used for each running cronjob.

func NewLog

func NewLog(job string) *Log

NewLog creates a new logger

func (*Log) Fields

func (l *Log) Fields(logger *log.Logger) *log.Entry

func (*Log) Finish

func (l *Log) Finish(storage *Storage, err error) (*LogEntry, error)

Finish finalizes the logs and write to the database. The error field should be for the command's error.

func (*Log) Stderr

func (l *Log) Stderr() *logErr

Stderr returns a struct that implements io.Writer.

func (*Log) Stdout

func (l *Log) Stdout() *logOut

Stdout returns a struct that implements io.Writer.

type LogEntry

type LogEntry struct {
	Name     string         `db:"name"`
	ExitCode int            `db:"exit_code"`
	Output   types.JSONText `db:"output"`
	Stamp    time.Time      `db:"stamp"`
	Duration time.Duration  `db:"duration"`
}

LogEntry is one log SQL entry

type Storage

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

func NewStorage

func NewStorage(handle *sqlx.DB) *Storage

func (*Storage) SaveJob

func (s *Storage) SaveJob(ctx context.Context, name, description string) error

func (*Storage) SaveLog

func (s *Storage) SaveLog(ctx context.Context, name string, stamp time.Time, duration time.Duration, output string, exitCode int) error

Jump to

Keyboard shortcuts

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