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 Subscription ¶
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
func New ¶
func New(subscriptions []Subscription, remoteSha RemoteShaFunc, sshEnv []string, logger *slog.Logger) *Watcher
Click to show internal directories.
Click to hide internal directories.