Documentation
¶
Index ¶
- type Activity
- type EmbedConfig
- type EmbedHooks
- type Instance
- func (i *Instance) Close() error
- func (i *Instance) Handler() http.Handler
- func (inst *Instance) PurgeOtherHosts(keepHost string) error
- func (inst *Instance) SetActiveWorktree(key string)
- func (inst *Instance) SetWatchedMRs(mrs []WatchedMR)
- func (inst *Instance) SetWorktreeLinks(links []WorktreeLink) error
- func (i *Instance) StartSync(ctx context.Context)
- func (i *Instance) StopSync()
- type MergeRequestSummary
- type Options
- type Repo
- type RepoRef
- type RepoSyncResult
- type ThemeConfig
- type UIConfig
- type WatchedMR
- type WorktreeLink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmbedConfig ¶
type EmbedConfig = server.EmbedConfig
Type aliases so external callers don't need to import internal packages.
type EmbedHooks ¶
type EmbedHooks struct {
OnMRSynced func(MergeRequestSummary)
OnSyncCompleted func(results []RepoSyncResult)
}
EmbedHooks provides lifecycle callbacks for embedded consumers.
Concurrency:
- OnMRSynced fires after each merge request is synced. Sync processes repos in parallel, so this callback may be invoked from multiple goroutines concurrently (one per in-flight repo sync). Implementations must be safe for concurrent use and must not block indefinitely or they will stall sync progress.
- OnSyncCompleted fires once at the end of each sync pass on the goroutine that drives the sync, so it is not invoked concurrently with itself.
Hooks should be set before calling StartSync. Mutating the hook fields while a sync is in flight is not safe.
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance holds a running middleman server and its resources.
func New ¶
New creates a middleman Instance from the given options. Either Token or ResolveToken must yield a non-empty token. Either DBPath or DataDir must be provided.
func (*Instance) PurgeOtherHosts ¶
PurgeOtherHosts deletes all data for platform hosts other than keepHost.
func (*Instance) SetActiveWorktree ¶
SetActiveWorktree sets the key of the currently focused worktree. This is bootstrap-only state: it is injected into the initial HTML page load. An already-loaded SPA will not see the change until the next full page load. For live updates, mutate window.__middleman_config.ui.activeWorktreeKey in the browser and call window.__middleman_notify_config_changed().
func (*Instance) SetWatchedMRs ¶
SetWatchedMRs sets the list of merge requests to sync on a fast interval. Replaces any previous watch list.
func (*Instance) SetWorktreeLinks ¶
func (inst *Instance) SetWorktreeLinks( links []WorktreeLink, ) error
SetWorktreeLinks replaces all worktree links atomically.
func (*Instance) StartSync ¶
StartSync begins periodic GitHub sync in the background. The context is used for cancellation during Close.
StartSync must be called at most once per Instance. Once StopSync (or Close) has stopped the syncer, the underlying Syncer cannot be restarted — a subsequent StartSync call is a silent no-op. Construct a new Instance if sync must run again.
func (*Instance) StopSync ¶
func (i *Instance) StopSync()
StopSync stops the periodic GitHub sync. This operation is terminal: the underlying Syncer permanently refuses further Start or TriggerRun calls after Stop, so callers that need to resume sync must create a new Instance.
Safe to call concurrently. The cancelHook check/call/reset is protected by cancelHookOnce so only the first caller cancels the stack-detection context. i.syncer.Stop() runs on every call by design: Syncer.Stop waits up to stopGracePeriod on each call, so a Close() following a StopSync() that hit the grace-period timeout can still re-wait for lingering work rather than closing the database out from under it.
type MergeRequestSummary ¶
type MergeRequestSummary struct {
MergeRequestID int64
RepoOwner string
RepoName string
Number int
State string
Title string
IsDraft bool
CIStatus string
ReviewDecision string
PlatformHost string
CIChecksJSON string
UpdatedAt time.Time
}
MergeRequestSummary is a lightweight snapshot of a synced MR, passed to EmbedHooks callbacks.
type Options ¶
type Options struct {
// Token is a static GitHub token. Used when ResolveToken
// is nil.
Token string
// ResolveToken returns a GitHub token for the given platform
// host (e.g. "github.com"). Preferred over Token for
// embedded use cases that need per-host auth.
ResolveToken func(ctx context.Context, host string) (string, error)
// DataDir is the directory for middleman state. Required if
// DBPath is not set.
DataDir string
// DBPath overrides the DataDir-derived database path. When
// set, the host owns the SQLite file and DataDir may be
// omitted.
DBPath string
BasePath string
SyncInterval time.Duration
WatchInterval time.Duration
Repos []Repo
Activity Activity
Assets fs.FS
EmbedConfig *server.EmbedConfig
EmbedHooks *EmbedHooks
}
Options configures a middleman Instance for embedding.
type Repo ¶
type Repo struct {
Owner string
Name string
PlatformHost string // e.g. "github.com" or GHE hostname
}
Repo identifies a GitHub repository to monitor.
type RepoSyncResult ¶
type RepoSyncResult struct {
Owner string
Name string
PlatformHost string
Error string // empty on success
}
RepoSyncResult holds the outcome of syncing a single repo.
type ThemeConfig ¶
type ThemeConfig = server.ThemeConfig
Type aliases so external callers don't need to import internal packages.
type WorktreeLink ¶
type WorktreeLink = db.WorktreeLink
Type aliases so external callers don't need to import internal packages.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
e2e-server
command
|
|
|
middleman
command
|
|
|
middleman-openapi
command
|
|
|
testify-helper-check
command
|
|
|
internal
|
|
|
apiclient/generated
Package generated provides primitives to interact with the openapi HTTP API.
|
Package generated provides primitives to interact with the openapi HTTP API. |
|
testutil/cmd/seed-roborev
command
|
|
|
tools
|
|