Documentation
¶
Overview ¶
Package runtime encapsulates the unified IPC bootstrap sequence that every Pando entrypoint follows: open the database, derive ports, try the IPC lock, and wire the leader or follower role accordingly.
The IPC role no longer has anything to do with database writes: every instance opens pando.db read-write through the multi-writer engine (internal/db). The lock only elects the leader that runs the singleton background jobs (code index and its watcher, evaluator sweeps) and serves the IPC bus (instance browsing, remote view, hot-peer delegation).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BootstrapResult ¶
type BootstrapResult struct {
Role Role
// Querier is the db.Querier callers should use for all DB operations: a
// direct querier on SQLDB in every role.
Querier db.Querier
// SQLDB is the read-write connection pool on pando.db (migrations applied).
SQLDB *sql.DB
// Bus is non-nil only on the leader.
Bus *ipc.Bus
// IPCClient is non-nil only on followers (heartbeat subscription).
IPCClient *ipc.Client
InstanceID string
PubPort int
RPCPort int
// LockFile is the open flock file held by the leader, nil on followers.
LockFile *os.File
// Watcher monitors leader liveness. Always non-nil.
Watcher *failover.Watcher
// Cleanup releases all resources acquired during Bootstrap in reverse order.
// The caller MUST call this exactly once on shutdown.
Cleanup func()
}
BootstrapResult carries everything a caller needs after Bootstrap returns. Call Cleanup() on shutdown to release resources in correct order.
func Bootstrap ¶
func Bootstrap(ctx context.Context, workdir, instanceID string) (*BootstrapResult, error)
Bootstrap runs the unified startup sequence for the given workdir.
- Open pando.db read-write through the engine (migrations serialised across processes by internal/db).
- Derive deterministic PUB/RPC ports from the path.
- Attempt to acquire the exclusive IPC lock.
- Leader: create the Bus and the leader watcher.
- Follower: create the IPC client and a follower watcher.
On lock error the function continues as leader so the caller does not lose functionality — consistent with the existing root.go behaviour.