index

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 11 Imported by: 0 modules, 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 index owns the branch→index mapping of a project's worktrees. It feeds the port formula and the compose project name, so an index must never change once a stack exists: allocated once, recorded, recovered from docker.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoIndex = errors.New("no recorded index")

ErrNoIndex means the branch has no recorded index and no docker trace: as far as stacks are concerned, this worktree never started one.

Functions

func MatchBranch

func MatchBranch(labels []string, repoName, branch string) (int, string, bool)

MatchBranch finds the label belonging to this repo and branch among compose project labels. It extracts the candidate integer then rebuilds the canonical name, so stack.ProjectName stays the single naming authority.

Types

type Mode

type Mode int

Mode says whether a resolution may invent a new index. Commands that bring a stack up may; commands that address an existing stack (stop, remove, exec) must not, or they would "find" a stack that never existed.

const (
	MustExist Mode = iota
	MayAllocate
)

type Resolver

type Resolver struct {
	ConfigPath string
	Runner     execx.Runner
	Name       string // project name in the registry
	RepoName   string // filepath.Base of the project directory
	Out        io.Writer
	// Conflicts says why index n must not be handed out, or "" when it may: with
	// a stride of 1, services one port apart collide on neighbouring indices.
	// It runs under the registry lock, given the registry that lock holds.
	Conflicts func(c *config.Config, n int) string
}

func (*Resolver) Recorded

func (r *Resolver) Recorded() map[string]int

func (*Resolver) Release

func (r *Resolver) Release(branch string) error

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, branch string, pos int, mode Mode) (int, error)

Resolve tries, first answer winning: recorded → backfill from docker labels → git position if free and clean → allocation (MayAllocate only). pos is that position, kept so worktrees older than recorded indices keep their .env ports.

Jump to

Keyboard shortcuts

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