small

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 6 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstLine

func FirstLine(s string) string

FirstLine keeps a card's one line summary to one line.

func HasTag

func HasTag(tags []string, want string) bool

func IsParked

func IsParked(t *store.Task) bool

IsParked reports whether a card is parked.

func LaunchKeys

func LaunchKeys(taskID, resume string) []string

LaunchKeys is the set of locks a launch or restart must hold across its check-then-spawn region: the card it lands on, and the conversation it resumes. Either may be empty, which drops out of the set.

func LaunchResumeKey

func LaunchResumeKey(resume string) string

func LaunchTaskKey

func LaunchTaskKey(taskID string) string

LaunchTaskKey and LaunchResumeKey namespace the two kinds of key so a card id and a resume id that happen to be the same string cannot collide on one lock.

func WriteJSON

func WriteJSON(w http.ResponseWriter, code int, v any)

WriteJSON answers code with v as JSON.

func WriteJSONErr

func WriteJSONErr(w http.ResponseWriter, code int, err error)

Types

type ErrString

type ErrString string

ErrString is an error from a literal, without reaching for fmt.

func (ErrString) Error

func (e ErrString) Error() string

type KeyedMutex

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

KeyedMutex serializes work that shares a key.

It is the lock that makes a launch's check-then-spawn region atomic against another caller. `launch.go` reads whether a runner is live on a card, or whether a conversation is already resumed somewhere, and only afterwards spawns and registers the process that would change those answers. Two callers racing through that gap both see "not live" and both spawn onto the one conversation, which is the braided-transcript corruption launch.go's own comments warn about. Holding this across the gap closes it.

A mutex is created on first use and kept. The keys are card ids and resume ids, a bounded set, so a handful of idle mutexes left behind cost nothing and buy a design with no reference counting to get wrong.

func NewKeyedMutex

func NewKeyedMutex() *KeyedMutex

func (*KeyedMutex) HeldKey

func (k *KeyedMutex) HeldKey() string

HeldKey is a key whose mutex is held now, or "".

func (*KeyedMutex) Lock

func (k *KeyedMutex) Lock(keys ...string) func()

Lock takes every key's mutex and returns the release.

SORTED AND DEDUPED, which is the whole reason a caller passes the set at once rather than locking one key and then another. Two callers asking for the same two keys in the opposite order would deadlock, each holding the one the other wants; a single sorted acquisition order removes that. An empty set is a valid no-op, so a plain launch that names neither a card nor a resume is not serialized against anything.

func (*KeyedMutex) TryLock added in v0.0.4

func (k *KeyedMutex) TryLock(keys ...string) (func(), bool)

TryLock takes every key's mutex without waiting, or none of them and false.

Jump to

Keyboard shortcuts

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