store

package
v0.0.0-...-332dcef Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DuckDBStore

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

DuckDBStore implements Store using DuckDB.

func NewDuckDBStore

func NewDuckDBStore(dsn string) (*DuckDBStore, error)

NewDuckDBStore creates a new DuckDB-backed store. Pass dsn="" for in-memory, or a file path for persistent storage.

func (*DuckDBStore) Close

func (s *DuckDBStore) Close() error

Close closes the underlying database connection.

func (*DuckDBStore) Init

func (s *DuckDBStore) Init(ctx context.Context) error

Init creates the log_entries and patterns tables if they do not exist.

func (*DuckDBStore) InsertLog

func (s *DuckDBStore) InsertLog(ctx context.Context, entry LogEntry) error

InsertLog stores a single log entry.

func (*DuckDBStore) InsertLogBatch

func (s *DuckDBStore) InsertLogBatch(ctx context.Context, entries []LogEntry) error

InsertLogBatch stores multiple log entries in a single transaction.

func (*DuckDBStore) InsertPatterns

func (s *DuckDBStore) InsertPatterns(ctx context.Context, patterns []Pattern) error

InsertPatterns upserts patterns into the patterns table.

func (*DuckDBStore) InternalDB

func (s *DuckDBStore) InternalDB() *sql.DB

InternalDB returns the underlying *sql.DB for direct SQL queries.

func (*DuckDBStore) PatternCounts

func (s *DuckDBStore) PatternCounts(ctx context.Context) (map[string]int, error)

PatternCounts returns the number of log entries per pattern semantic ID.

func (*DuckDBStore) PatternSummaries

func (s *DuckDBStore) PatternSummaries(ctx context.Context) ([]PatternSummary, error)

PatternSummaries returns all patterns with their occurrence counts, joined with pattern metadata from the patterns table.

func (*DuckDBStore) Patterns

func (s *DuckDBStore) Patterns(ctx context.Context) ([]Pattern, error)

Patterns returns all patterns from the patterns table.

func (*DuckDBStore) QueryByPattern

func (s *DuckDBStore) QueryByPattern(ctx context.Context, pattern string) ([]LogEntry, error)

QueryByPattern returns log entries matching the given pattern semantic ID via labels.

func (*DuckDBStore) QueryLogs

func (s *DuckDBStore) QueryLogs(ctx context.Context, opts QueryOpts) ([]LogEntry, error)

QueryLogs returns log entries matching the given options.

type LogEntry

type LogEntry struct {
	ID            int64
	LineNumber    int
	EndLineNumber int
	Timestamp     time.Time
	Raw           string
	Labels        map[string]string
}

LogEntry represents a single stored log line.

type Pattern

type Pattern struct {
	PatternUUIDString string
	PatternType       string
	RawPattern        string
	SemanticID        string
	Description       string
}

Pattern represents a discovered log pattern with optional semantic labels.

type PatternSummary

type PatternSummary struct {
	PatternUUIDString string
	Pattern           string
	Count             int
	PatternType       string
	SemanticID        string
	Description       string
}

PatternSummary holds a pattern and its occurrence count.

type QueryOpts

type QueryOpts struct {
	Pattern string
	From    time.Time
	To      time.Time
	Limit   int
}

QueryOpts specifies filters for querying log entries.

type Store

type Store interface {
	// Init creates tables if they don't exist.
	Init(ctx context.Context) error
	// InsertLog stores a parsed log entry.
	InsertLog(ctx context.Context, entry LogEntry) error
	// InsertLogBatch stores multiple log entries.
	InsertLogBatch(ctx context.Context, entries []LogEntry) error
	// QueryByPattern returns entries matching a pattern semantic ID via labels.
	QueryByPattern(ctx context.Context, pattern string) ([]LogEntry, error)
	// QueryLogs returns entries matching the given options.
	QueryLogs(ctx context.Context, opts QueryOpts) ([]LogEntry, error)
	// PatternSummaries returns all patterns with their counts.
	PatternSummaries(ctx context.Context) ([]PatternSummary, error)
	// InsertPatterns upserts patterns into the patterns table.
	InsertPatterns(ctx context.Context, patterns []Pattern) error
	// Patterns returns all patterns.
	Patterns(ctx context.Context) ([]Pattern, error)
	// PatternCounts returns the number of log entries per pattern_id.
	PatternCounts(ctx context.Context) (map[string]int, error)
	// InternalDB returns the underlying *sql.DB for direct SQL queries.
	// Only use this when no interface method covers the needed operation.
	InternalDB() *sql.DB
	// Close releases resources.
	Close() error
}

Store persists log entries and patterns.

Jump to

Keyboard shortcuts

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