server

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package server implements gitrakz's HTTP handlers as the generated api.StrictServerInterface. Every external dependency (storage, the transform engine, sessionization, the gh sync controller, and the LLM template composer) is expressed as a small interface owned by this package, so Server is fully unit-testable without a real DB, LLM, or gh CLI. Production wiring (a later chunk, the "service" layer) supplies the concrete implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Store          Store
	Engine         Engine
	Sessionizer    Sessionizer
	SyncController SyncController
	LLMComposer    LLMComposer
}

Deps collects every dependency Server needs to satisfy api.StrictServerInterface.

type Engine

type Engine interface {
	Run(
		ctx context.Context,
		tmpl template.Template,
		timeline types.Timeline,
		form types.FormValues,
	) (blocks.Document, error)
}

Engine runs a template's transform pipeline over a selected timeline and renders it into a display Document. *engine.Engine satisfies it in production.

type LLMComposer

type LLMComposer interface {
	GenerateTemplate(
		ctx context.Context,
		description string,
	) (template.Template, error)
}

LLMComposer drafts a new template from a natural-language description. The service layer wires this to elelem.

type Server

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

Server implements api.StrictServerInterface entirely against the interfaces in Deps, so it never talks to a real DB/LLM/gh CLI directly.

func New

func New(deps Deps) *Server

New builds a Server backed by deps.

func (*Server) CreateTemplate

CreateTemplate saves a new, non-builtin template from the client- submitted TemplateInput, assigning it a fresh id.

func (*Server) DeleteTemplate

DeleteTemplate removes a custom template. Builtin templates are not deletable.

func (*Server) ExportDocument

ExportDocument resolves a Document (inline, or by running a template) and serializes it in the requested format.

The generated response only carries an application/octet-stream Body + ContentLength (VisitExportDocumentResponse hardcodes the content type and sets no other headers), so per-format content-type/filename distinction isn't expressible within the generated contract — every format returns as octet-stream bytes.

func (*Server) GenerateTemplate

GenerateTemplate LLM-composes a template draft from a description. Nothing is persisted — the caller reviews/edits/saves separately via CreateTemplate.

func (*Server) GetSyncStatus

GetSyncStatus returns the current sync status.

func (*Server) ListOwners

ListOwners returns every distinct owner with ingested activity.

func (*Server) ListRepos

ListRepos returns every distinct repo ingested under the required "owner" query parameter.

func (*Server) ListSessions

ListSessions derives per-owner work sessions over the filtered range.

The Gap query parameter (a per-request sessionization override) is not forwarded: the Sessionizer contract this handler is built against takes only a timeline, so gap tuning is the service layer's concern when it wires Sessionizer to the sessionize primitive, not this handler's.

func (*Server) ListTemplates

ListTemplates returns every saved template, built-in and custom.

func (*Server) ListTimeline

ListTimeline returns one page of the filtered, newest-first event timeline.

func (*Server) RunTemplate

RunTemplate resolves the request's templateId and runs its transform pipeline over the (optionally filtered) timeline, returning the rendered Document.

RunRequest carries only a templateId (no inline template field in the generated schema), so a template is always resolved by id — there is no inline-template path here, unlike ExportDocument's inline document.

func (*Server) TriggerSync

TriggerSync runs one incremental `gh` sync and reports its outcome as an accepted job. ghsync.SyncResult carries no id of its own, so a fresh one is minted per call purely to satisfy the SyncJob response shape.

func (*Server) UpdateTemplate

UpdateTemplate replaces a custom template's fields with the submitted TemplateInput. Builtin templates are not editable.

type Sessionizer

type Sessionizer interface {
	Sessions(
		ctx context.Context,
		timeline types.Timeline,
	) ([]types.Session, error)
}

Sessionizer derives per-owner work sessions from a raw timeline. The service layer wires this to the sessionize transform primitive.

type Store

type Store interface {
	ListOwners(ctx context.Context) ([]string, error)
	ListRepos(ctx context.Context, owner string) ([]string, error)
	QueryTimeline(
		ctx context.Context,
		filter db.TimelineFilter,
	) ([]types.Event, bool, error)
	ListTemplates(ctx context.Context) ([]template.Template, error)
	GetTemplate(ctx context.Context, id string) (template.Template, error)
	SaveTemplate(ctx context.Context, tmpl template.Template) error
	DeleteTemplate(ctx context.Context, id string) error
}

Store is the persistence surface the HTTP handlers need. *db.Store satisfies it in production; tests supply an in-memory fake.

type SyncController

type SyncController interface {
	Trigger(ctx context.Context) (ghsync.SyncResult, error)
	Status(ctx context.Context) (api.SyncStatus, error)
}

SyncController drives, and reports on, the background `gh` sync. The service layer wires this to the running syncer.

Jump to

Keyboard shortcuts

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