Documentation
¶
Overview ¶
Package reposync keeps server-managed repo checkouts in step with their remotes. On an interval it mirror-fetches each managed registry entry — using a GitHub App installation token for auth — and triggers the entry's refresh so connected clients see the update, with no local actor required.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRepoNotManaged = errors.New("reposync: repo not managed")
ErrRepoNotManaged is returned by SyncRepo when no managed registry entry matches the requested owner/name — e.g. a webhook arrives for a repo that was never onboarded, or for the unmanaged -cwd dev repo.
Functions ¶
This section is empty.
Types ¶
type Coalescer ¶
type Coalescer struct {
// contains filtered or unexported fields
}
Coalescer debounces and collapses repeated sync triggers for the same repo. A trigger (re)arms a per-repo timer; the sync runs only after the timer's quiet window elapses with no newer trigger, so a burst of pushes — e.g. a whole stack submit — yields a single fetch once they settle. At most one sync runs per repo at a time; a trigger that lands while one is in flight sets a pending flag for exactly one follow-up. This bounds live goroutines to the number of distinct repos seeing traffic and keeps git subprocesses in check — the webhook receiver can hand off every delivery without fanning out.
func NewCoalescer ¶
NewCoalescer wraps sync. A non-positive timeout uses defaultSyncTimeout; a negative debounce uses defaultDebounce, while a zero debounce dispatches immediately (no quiet window).
func (*Coalescer) Trigger ¶
Trigger requests a sync for repo and returns immediately. It is safe for concurrent use. The sync is debounced: a burst of triggers keeps bumping the timer out and collapses into one run once the quiet window elapses; triggers that land while a sync is already running coalesce into a single follow-up.
type SyncFunc ¶
SyncFunc mirror-fetches and refreshes one repo by its GitHub coordinates. (*Syncer).SyncRepo satisfies it.
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
Syncer mirror-fetches managed registry entries on an interval.
func New ¶
New builds a Syncer. provider may be nil (no GitHub App configured), in which case fetches carry no auth and only public repos refresh.
func (*Syncer) Run ¶
Run mirror-fetches all managed entries every interval until ctx is canceled. It blocks; start it in a goroutine.
func (*Syncer) SyncRepo ¶
SyncRepo mirror-fetches and refreshes the single managed entry matching owner/name. It is the per-repo unit of work shared by the interval loop and the webhook receiver: the loop calls syncEntry directly over the entries it already holds, while the webhook path arrives with only GitHub coordinates and resolves the entry here. Returns ErrRepoNotManaged when no managed repo matches, so a webhook for an un-onboarded repo is a clean no-op.
type TokenProvider ¶
type TokenProvider interface {
InstallationToken(ctx context.Context, owner, name string) (string, error)
}
TokenProvider mints a credential for fetching owner/name. The concrete implementation is *github.AppTokenProvider; a nil provider fetches without auth (public repos only).