repowatcher

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package repowatcher polls remote git repositories and dispatches to subscribers when a new SHA is detected.

Multiple subscriptions for the same url-branch pair share one polling goroutine, running at the minimum of their requested intervals. Handlers for a group are called sequentially in registration order.

watcher := repowatcher.New([]repowatcher.Subscription{
    {
        URL:      "git@github.com:org/repo.git",
        Branch:   "main",
        Interval: 30 * time.Second,
        Handler:  func(ctx context.Context, sha string) { fmt.Println("new commit", sha) },
    },
}, remoteSha, sshEnv, logger)
watcher.Start(appCtx)
defer watcher.Stop()

Index

Constants

View Source
const DefaultPollInterval = 60 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type RemoteShaFunc

type RemoteShaFunc func(ctx context.Context, url, branch string, sshEnv []string) (string, error)

type Subscription

type Subscription struct {
	URL      string
	Branch   string
	Interval time.Duration
	Handler  func(ctx context.Context, sha string)
}

type Watcher

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

func New

func New(subscriptions []Subscription, remoteSha RemoteShaFunc, sshEnv []string, logger *slog.Logger) *Watcher

func (*Watcher) Start

func (watcher *Watcher) Start(appCtx context.Context)

func (*Watcher) Stop

func (watcher *Watcher) Stop()

Jump to

Keyboard shortcuts

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