frag

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 25 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package frag is the Frag module: quick capture into a Fragments Engine (FE).

A capture is queued in the module's own store first (so it is never lost and capturing works offline) and delivered behind it by a worker, as an fe.capture.v1 manifest, with retries, receipts and idempotency. The outbox shows where each capture is and lets the owner retry or discard one. It is a port of Basalisk's built-in Frag in personal mode: the owner's own key, read from a file at the moment of use.

Delivery is off until the owner turns it on (frag.delivery) and sets the FE address (frag.fe_url) and the key file (frag.fe_token_file).

What the module knows about the moment of a capture (the window the owner was in when the draft began and when it was saved) is kept with the queued row and never sent to FE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTags

func ParseTags(s string) []string

ParseTags splits "a, b,,c" into [a b c].

Types

type Capture

type Capture struct {
	Sequence           int64           `json:"sequence"`
	CaptureID          string          `json:"capture_id"`
	State              string          `json:"state"`
	Code               string          `json:"code"`
	Content            string          `json:"content"`
	Tags               []string        `json:"tags"`
	Context            json.RawMessage `json:"context,omitempty"`
	CreatedAt          string          `json:"created_at"`
	UpdatedAt          string          `json:"updated_at"`
	Attempts           int             `json:"attempts"`
	NextAttempt        int64           `json:"next_attempt,omitempty"`
	MayHaveSent        bool            `json:"may_have_sent"`
	Delivering         bool            `json:"delivering"`
	FragmentID         string          `json:"fragment_id,omitempty"`
	FragmentRevisionID string          `json:"fragment_revision_id,omitempty"`
	FragmentURL        string          `json:"fragment_url,omitempty"`
}

Capture is one row of the queue, as the outbox shows it.

type Check

type Check struct {
	OK            bool   `json:"ok"`
	FEURL         string `json:"fe_url,omitempty"`
	SchemaVersion string `json:"schema_version,omitempty"`
	Reason        string `json:"reason,omitempty"`
}

Check is the answer of a read against FE.

type Draft

type Draft struct {
	Content   string          `json:"content"`
	Tags      string          `json:"tags"`
	DraftAt   string          `json:"draft_at,omitempty"`
	CaptureID string          `json:"capture_id,omitempty"`
	Context   json.RawMessage `json:"context,omitempty"`
	// contains filtered or unexported fields
}

Draft is the capture being written. It is kept until it is committed.

type Mod

type Mod struct {
	// Client, when set before Start, is the HTTP client delivery uses.
	Client *http.Client
	// contains filtered or unexported fields
}

Mod is the Frag module.

func New

func New() *Mod

New is the module. Its HTTP client is the default one; tests set Client.

func (*Mod) Manifest

func (m *Mod) Manifest() module.Manifest

Manifest says what the module brings.

func (*Mod) Start

func (m *Mod) Start(_ context.Context, h module.Host) error

Start opens the store, serves the routes and starts the delivery worker.

func (*Mod) Stop

func (m *Mod) Stop(context.Context) error

Stop ends the worker.

type Moment

type Moment struct {
	Window *Window `json:"window,omitempty"`
}

Moment is what a capture remembers about when it was drafted or saved.

type OwnerContext

type OwnerContext struct {
	Draft *Moment `json:"draft,omitempty"`
	Save  *Moment `json:"save,omitempty"`
}

OwnerContext is kept with the row and never sent to FE.

type Payload

type Payload struct {
	CaptureID   string   `json:"capture_id"`
	Content     string   `json:"content"`
	Tags        []string `json:"tags"`
	DraftAt     string   `json:"draft_at"`
	SubmittedAt string   `json:"submitted_at"`
}

Payload is what a capture's row keeps for delivery: exactly what FE receives, and when.

type Status

type Status struct {
	Delivery bool           `json:"delivery"`
	Ready    bool           `json:"ready"`
	Reason   string         `json:"reason,omitempty"`
	FEURL    string         `json:"fe_url,omitempty"`
	Counts   map[string]int `json:"counts"`
}

Status is how captures are delivered now.

type Window

type Window struct {
	View   string `json:"view,omitempty"`
	Module string `json:"module,omitempty"`
	Title  string `json:"title,omitempty"`
	Kind   string `json:"kind,omitempty"`
	Ref    string `json:"ref,omitempty"`
	URL    string `json:"url,omitempty"`
}

Window is the owner's window at a moment: what it showed, as the desk knows it.

Jump to

Keyboard shortcuts

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