journal

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package journal provides an append-only JSONL activity ledger. Every GitLab operation performed through ggvalet is recorded here so the operator can generate time-boxed manager reports without touching the API again.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

type Entity string

Entity describes the GitLab resource type.

const (
	EntityIssue     Entity = "issue"
	EntityEpic      Entity = "epic"
	EntityMilestone Entity = "milestone"
	EntityWorkItem  Entity = "workitem"
	EntityMR        Entity = "mr"
	EntityLabel     Entity = "label"
	EntityNote      Entity = "note"
	EntityPipeline  Entity = "pipeline"
	EntityJob       Entity = "job"
	EntityArtifact  Entity = "artifact"
)

type Entry

type Entry struct {
	ID        string    `json:"id"`
	Timestamp time.Time `json:"ts"`
	Host      string    `json:"host"` // e.g. "gitlab.thalesdigital.io"
	Op        Op        `json:"op"`
	Entity    Entity    `json:"entity"`
	Project   string    `json:"project,omitempty"`
	Group     string    `json:"group,omitempty"`
	EntityID  int       `json:"entity_id,omitempty"`
	IID       int       `json:"iid,omitempty"`
	Title     string    `json:"title,omitempty"`
	URL       string    `json:"url,omitempty"`
	Outcome   Outcome   `json:"outcome"`
	Detail    string    `json:"detail,omitempty"`
	Tags      []string  `json:"tags,omitempty"`
}

Entry is one immutable journal record.

type Filter

type Filter struct {
	Since    time.Time
	Until    time.Time
	Host     string // empty = all hosts
	Ops      []Op
	Entities []Entity
	Project  string
	Group    string
	Outcome  Outcome // empty = all
}

Filter controls which entries are returned by Query.

type Journal

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

Journal is the append-only ledger backed by a JSONL file.

func Open

func Open(path string) (*Journal, error)

Open opens (or creates) the journal at the given path.

func (*Journal) Query

func (j *Journal) Query(f Filter) ([]Entry, error)

Query reads all entries from the ledger and returns those matching f.

func (*Journal) Record

func (j *Journal) Record(e Entry) error

Record appends e to the ledger. Thread-safe via O_APPEND.

type Op

type Op string

Op describes the kind of mutation performed.

const (
	OpCreate   Op = "create"
	OpUpdate   Op = "update"
	OpClose    Op = "close"
	OpReopen   Op = "reopen"
	OpComment  Op = "comment"
	OpList     Op = "list"
	OpAssign   Op = "assign"
	OpDelete   Op = "delete"
	OpRun      Op = "run"
	OpRetry    Op = "retry"
	OpCancel   Op = "cancel"
	OpView     Op = "view"
	OpDownload Op = "download"
)

type Outcome

type Outcome string

Outcome is the terminal state of the operation.

const (
	OutcomeOK  Outcome = "ok"
	OutcomeErr Outcome = "err"
)

type Stats

type Stats struct {
	Total    int
	ByHost   map[string]int
	ByEntity map[Entity]int
	ByOp     map[Op]int
	Errors   int
}

Stats returns a breakdown of entries for display.

func ComputeStats

func ComputeStats(entries []Entry) Stats

Jump to

Keyboard shortcuts

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