db

package
v0.0.10 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidLogScope = errors.New("invalid log project or client id")

Functions

This section is empty.

Types

type IngestLog

type IngestLog struct {
	EventKey [32]byte
	Log      types.StoredLog
}

type LastCursor

type LastCursor struct {
	Timestamp      time.Time
	SequenceNumber int
	ID             int64
	IsBackward     bool
}

type LogPage

type LogPage struct {
	Logs           []types.StoredLog
	Instances      *[]string
	ForwardCursor  *LastCursor
	BackwardCursor *LastCursor
	IsLastPage     bool
	Range          *LogRange
}

func (*LogPage) ToPath

func (l *LogPage) ToPath(projectId, clientId string, instances *[]string, cursor *LastCursor, direction, search string) string

type LogPageRequest

type LogPageRequest struct {
	ProjectId string
	ClientId  string
	Instances *[]string
	PageSize  int64
	LogLineId *string
	Cursor    *LastCursor
	Search    string
	Range     *LogRange
}

type LogRange

type LogRange struct {
	From     time.Time
	To       time.Time
	FromDate string
	ToDate   string
	Offset   int
}

func ParseLogRange

func ParseLogRange(fromDate, toDate string, offsetMin int) (LogRange, error)

ParseLogRange turns inclusive local calendar dates into a half-open UTC interval. offsetMin is JavaScript's getTimezoneOffset: minutes to add to local time to get UTC.

func ParseLogTimeRange added in v0.0.8

func ParseLogTimeRange(fromAt, toAt string) (LogRange, error)

ParseLogTimeRange accepts an absolute, half-open interval.

func (*LogRange) Query added in v0.0.8

func (r *LogRange) Query() url.Values

type LogService

type LogService interface {
	GetLogs(ctx context.Context, req LogPageRequest) (LogPage, error)
	GetInstances(ctx context.Context, projectId string, clientId string) ([]string, error)
	SearchLogs(ctx context.Context, query string, projectId string, clientId string, instances *[]string, pageSize int64, lastCursor *LastCursor) ([]types.StoredLog, error)
}

type PostgresLogService

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

func NewLogService

func NewLogService(pool *pgxpool.Pool, liveLogs *live.Logs) *PostgresLogService

func (*PostgresLogService) CommitLogs

func (self *PostgresLogService) CommitLogs(ctx context.Context, logs []IngestLog) ([]persistence.IngestLogResult, error)

CommitLogs returns one result per input after a successful write. Live delivery is best effort and must never turn a commit into a retry.

func (*PostgresLogService) GetInstances

func (self *PostgresLogService) GetInstances(ctx context.Context, projectId string, clientId string) ([]string, error)

GetInstances implements LogRepository.

func (*PostgresLogService) GetLogs

func (self *PostgresLogService) GetLogs(ctx context.Context, req LogPageRequest) (LogPage, error)

GetLogs implements LogRepository.

func (*PostgresLogService) SearchLogs

func (self *PostgresLogService) SearchLogs(ctx context.Context, query string, projectId string, clientId string, instances *[]string, pageSize int64, lastCursor *LastCursor) ([]types.StoredLog, error)

Jump to

Keyboard shortcuts

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