session

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package session wires the index commands to their dependencies.

A sibling of the command packages rather than their parent: the parent registers them, so anything they share has to live beside them.

Package session wires the index commands to their dependencies.

A sibling of the command packages rather than their parent: the parent registers them, so anything they share has to live beside them.

Index

Constants

View Source
const DefaultDBPath = "phpbotscout.db"

DefaultDBPath is where the index lives when configuration says nothing.

View Source
const MinRefreshInterval = time.Minute

MinRefreshInterval is the shortest accepted refresh interval.

Every refresh fetches each source that may have moved. Seconds would put the bot in a polling loop against the forge, which is a denial of service aimed at the project's own infrastructure.

Variables

This section is empty.

Functions

func ClonesPath added in v0.14.0

func ClonesPath(p *props.Props) string

ClonesPath reports where the indexer keeps its clones.

func Credential

func Credential(p *props.Props) forge.CredentialSource

Credential composes the credential used to reach GitLab.

GTB owns this ladder. go/forge v0.8.0 moved credential precedence out of the module and into the consumer's stack, and vcs.ForgeCredential IS that stack — the same four rungs this project documents, in the same order: an environment variable NAME, a keychain reference, a literal, then the well-known variable.

Composing it here instead would be a second statement of the same precedence, which is the thing the move was meant to stop. It would also miss what GTB adds around it: origin reporting that can tell an operator WHICH rung resolved without printing the secret, and the documented reason forge.ConfigCredential is unsuitable (its stale-key probe reports a working auth.env configuration as stale when pointed at auth.value).

func DBPath

func DBPath(p *props.Props) string

DBPath reports where the index lives.

func Feed added in v0.15.0

func Feed(p *props.Props, db *store.DB) (*feed.Resolver, error)

Feed builds the estate feed reader, from index.feed.url or the estate's own feed, keeping the last good copy in db (spec 0034 D7, D8).

func ForgeURL added in v0.15.0

func ForgeURL(p *props.Props) string

ForgeURL is the forge a clone URL must name before a credential is sent to it, over either transport.

func Provider added in v0.15.0

func Provider(ctx context.Context, p *props.Props) (forge.Provider, error)

Provider builds the configured forge provider, which discovery and the release lookup share. One function, so the provider is constructed identically for every command and for the daemon's refresher.

func RefreshInterval added in v0.14.0

func RefreshInterval(p *props.Props) time.Duration

RefreshInterval reports the configured refresh interval, which staleness is judged against. A value serve would refuse falls back to the default rather than failing a status read.

func RenderReport

func RenderReport(w io.Writer, r indexer.Report)

RenderReport prints the outcome of an indexing run.

func RenderStatus

func RenderStatus(w io.Writer, statuses []indexer.SourceStatus, interval time.Duration)

RenderStatus prints per-source staleness, judged against the refresh interval.

func ResolveRefreshInterval added in v0.14.0

func ResolveRefreshInterval(raw string) (time.Duration, error)

ResolveRefreshInterval parses and bounds index.refresh_interval, defaulting when it is empty.

func SSH added in v0.14.0

func SSH(p *props.Props) (*indexer.SSH, error)

SSH reports the key the indexer clones with, or nil to clone over HTTPS (spec 0033 D2, OQ2). A key without a pinned known_hosts file is refused, as is either file missing, so the mistake surfaces before any source is fetched.

func Servers added in v0.11.0

func Servers(p *props.Props) []comms.ID

Servers reports the servers the configuration names, in order.

func Sites added in v0.15.0

func Sites(p *props.Props, w *index.Writer) ([]*siteindex.Indexer, error)

Sites builds an indexer for each published site in index.sites, writing through w (spec 0008). None is built unless one is named: configuration names a public site and never grants access to anything (section 3.3).

func Token

func Token(ctx context.Context, p *props.Props) string

Token resolves the credential used to clone.

An empty token is not an error: the corpus is public by construction, and a public repository clones unauthenticated. It only costs rate limit. A source that is configured but BROKEN is different, and is logged rather than swallowed — a silent empty token surfaces later as a confusing 401.

Types

type Releases added in v0.15.0

type Releases struct {
	Provider forge.Provider
}

Releases names a source's latest release through the forge, the release the forge itself reports rather than the newest tag (spec 0035 D2).

func (Releases) LatestRelease added in v0.15.0

func (r Releases) LatestRelease(ctx context.Context, path string) (string, error)

LatestRelease returns the tag of path's latest release, or an error wrapping forge.ErrReleaseNotFound when it has none.

type Session

type Session struct {
	Indexer *indexer.Indexer
	DB      *store.DB

	// Feed is the estate feed discovery reads.
	Feed *feed.Resolver
}

Session is an opened index with everything needed to work on it.

func Open

func Open(ctx context.Context, p *props.Props) (*Session, error)

Open wires an indexer from configuration.

func (*Session) Close

func (s *Session) Close() error

Close releases the database.

Jump to

Keyboard shortcuts

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