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) PurgeOtherHostsWithContext(ctx context.Context, keepHost string) error
- func (inst *Instance) SetActiveWorktree(key string)
- func (inst *Instance) SetWatchedMRs(mrs []WatchedMR)
- func (inst *Instance) SetWorktreeLinks(links []WorktreeLink) error
- func (inst *Instance) SetWorktreeLinksWithContext(ctx context.Context, 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. It wraps NewWithContext with context.Background(); callers that need to bound or cancel a slow ResolveToken callback should use NewWithContext directly.
Either Token or ResolveToken must yield a non-empty token. Either DBPath or DataDir must be provided.
func NewWithContext ¶
NewWithContext creates a middleman Instance from the given options. The provided ctx is used for ResolveToken lookups during initialization so hosts that depend on a slow secret store can bound it. A nil ctx is treated as context.Background() to preserve the panic-free contract of the older New(opts) entry point. ctx is not retained past New; runtime sync cancellation is controlled by StartSync / Close.
func (*Instance) PurgeOtherHosts ¶
PurgeOtherHosts deletes all data for platform hosts other than keepHost. Uses context.Background(); callers that need to bound a long-running purge should call PurgeOtherHostsWithContext instead.
func (*Instance) PurgeOtherHostsWithContext ¶
PurgeOtherHostsWithContext deletes all data for platform hosts other than keepHost under the given ctx. A nil ctx is treated as context.Background() so callers that previously used the context-less API do not hit database/sql's nil-ctx panic.
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. Uses context.Background(); callers that need cancellation should call SetWorktreeLinksWithContext.
func (*Instance) SetWorktreeLinksWithContext ¶
func (inst *Instance) SetWorktreeLinksWithContext( ctx context.Context, links []WorktreeLink, ) error
SetWorktreeLinksWithContext replaces all worktree links atomically under the given ctx. A nil ctx is treated as context.Background() so callers that previously used the context-less API do not hit database/sql's nil-ctx panic.
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. |
|
gitenv
Package gitenv centralizes stripping of inherited GIT_* environment variables that bind a child git process to a parent git context.
|
Package gitenv centralizes stripping of inherited GIT_* environment variables that bind a child git process to a parent git context. |
|
server
Package server exposes HTTP routes and, in this file, tracks passive tmux activity for workspace responses.
|
Package server exposes HTTP routes and, in this file, tracks passive tmux activity for workspace responses. |
|
testutil/cmd/seed-roborev
command
|
|
|
tools
|
|
|
migrationhistorycheck
command
|
|
|
nohttpmux
command
|
|