client

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is set at build time via -ldflags "-X main.version=...". It is copied from the main package at startup.

Functions

func Checkout

func Checkout(repoPath string, event protocol.EventMsg) error

Checkout switches to the correct ref based on the event.

func EnsureRepo

func EnsureRepo(reposDir, repoName, cloneURL string) (string, error)

EnsureRepo clones the repo if it doesn't exist, or fetches if it does.

func Run

func Run(ctx context.Context, cfg Config)

Run connects to the relay and processes events. Reconnects on failure.

func RunHook

func RunHook(ctx context.Context, repoPath, hook, hookLabel string, event protocol.EventMsg) error

RunHook executes a hook command in the repo directory.

func RunHookWithOutput

func RunHookWithOutput(ctx context.Context, repoPath, hook, hookLabel string, event protocol.EventMsg) (string, error)

RunHookWithOutput executes a hook and returns its combined output.

func StartAutoUpdater added in v0.2.0

func StartAutoUpdater(ctx context.Context)

StartAutoUpdater runs a background loop that checks for new releases every 5 minutes. When a newer version is found it replaces the running binary and exits so systemd (or the parent supervisor) can restart the service.

func StartRepoChecker added in v0.3.0

func StartRepoChecker(ctx context.Context, cfg Config)

StartRepoChecker runs a background loop that periodically walks the repos directory and verifies every cloned repository is healthy. Repos that are missing a .git directory or fail a basic git sanity check are re-cloned on the default branch. Repos already checked out on a branch are left as-is.

Repos are checked one at a time to avoid overwhelming the system.

Types

type Config

type Config struct {
	Relay       string   `yaml:"relay"`
	Token       string   `yaml:"token"`
	ClientID    string   `yaml:"client_id"`
	ReposDir    string   `yaml:"repos_dir"`
	Subscribe   []string `yaml:"subscribe"`
	AutoUpdate  bool     `yaml:"auto-update"`
	AutoCheck   *bool    `yaml:"auto-check"`
	MaxWorkers  int      `yaml:"max-workers"`
	LogLevel    string   `yaml:"log-level"`
	GlobalHooks struct {
		Pre  string `yaml:"pre"`
		Post string `yaml:"post"`
	} `yaml:"global-hooks"`
}

type EventHooks

type EventHooks struct {
	Pre  string `yaml:"pre"`
	Post string `yaml:"post"`
}

EventHooks defines pre/post hooks for a specific event or event.action.

type EventicConfig

type EventicConfig struct {
	Hooks struct {
		Pre  string `yaml:"pre"`
		Post string `yaml:"post"`
	} `yaml:"hooks"`
	Events map[string]EventHooks `yaml:"events"`
}

EventicConfig is the in-repo .eventic.yaml format.

Example:

hooks:
  pre: "echo preparing..."
  post: "echo done"
events:
  push:
    post: "bruce install .deploy/deploy.yml"
  pull_request:
    post: "make lint"
  pull_request.opened:
    post: "claude -p 'Review this PR' --headless"
  pull_request.synchronize:
    post: "make test"
  release.published:
    post: "/opt/scripts/notify-release.sh"
  workflow_run.completed:
    post: "/opt/scripts/on-build-failure.sh"
  issues.opened:
    post: "claude -p 'Triage this issue' --headless"
  check_suite.completed:
    post: "/opt/scripts/check-status.sh"
  deployment_status:
    post: "/opt/scripts/deploy-status.sh"

type HookSet

type HookSet struct {
	Pre       string // global pre hook — runs for every event
	Post      string // global post hook — runs for every event
	EventPre  string // event-specific pre hook
	EventPost string // event-specific post hook
}

HookSet holds all hooks resolved for a single event.

func DiscoverHooks

func DiscoverHooks(repoPath string, event protocol.EventMsg, globalPre, globalPost string) HookSet

DiscoverHooks checks the repo for .eventic.yaml or .deploy/deploy.yml and resolves global + event-specific hooks for the given event. globalPre and globalPost are fallback hooks from the client config that are used when a repo has no hooks of its own.

type RepoLocks added in v0.3.0

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

RepoLocks provides per-repository mutual exclusion so that concurrent events targeting the same repo are serialized (queued), while events for different repos run in parallel.

func NewRepoLocks added in v0.3.0

func NewRepoLocks() *RepoLocks

func (*RepoLocks) Lock added in v0.3.0

func (r *RepoLocks) Lock(repo string)

Lock acquires the mutex for the given repository. If another goroutine holds the lock for the same repo, the caller blocks until it is released.

func (*RepoLocks) Unlock added in v0.3.0

func (r *RepoLocks) Unlock(repo string)

Unlock releases the mutex for the given repository.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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