-
Notifications
You must be signed in to change notification settings - Fork 3
Bridge
BastiGame edited this page Jan 20, 2026
·
4 revisions
A Bridge serves as the head for a set of Galatic Managed Instances. It distributes the clusters across the instances and restarts them as needed or redistributes them across the instances.
It starts an IPC server, through which the instances connect.
import {Bridge} from "galactic.ts";
const bridge = new Bridge(
3000, // Port to run the bridge on
"MTM1ODUzMTk2MTQ3MT...", // Your bot token
["Guilds"], // Intents to use
2, // Shards per cluster
2 // Total of clusters
300000 // Recluster timeout in ms
);
bridge.start(); // Start the bridgeThe bridge outputs various events, which could be used for log outputs, for example.
this.bridge.on("EVENT_NAME", (...) => {
console.log(...)
})| Name | Signature | Occurance |
|---|---|---|
| CLUSTER_READY | (cluster: BridgeClientCluster, guilds: number, members: number) => void |
When a cluster reports ready, with the number of guilds and members it is in. |
| CLUSTER_STOPPED | (cluster: BridgeClientCluster) => void |
When a cluster stops. |
| CLUSTER_SPAWNED | (cluster: BridgeClientCluster, connection: BridgeClientConnection) => void |
When a cluster is spawned. |
| CLUSTER_RECLUSTER | (cluster: BridgeClientCluster, newConnection: BridgeClientConnection, oldConnection: BridgeClientConnection) => void |
When a cluster is moved to a new instance. |
| CLUSTER_HEARTBEAT_FAILED | (cluster: BridgeClientCluster, error: unknown) => void |
On failed heartbeat response from a cluster. |
| CLIENT_CONNECTED | (client: BridgeClientConnection) => void |
On new instance connection to the bridge. |
| CLIENT_DISCONNECTED | (client: BridgeClientConnection, reason: string) => void |
When an instance disconnects. |
| ERROR | (error: string) => void |
Internal errors during operations (e.g. reclustering without available target). |
| CLIENT_STOP | (instance: BridgeClientConnection) => void |
Before an instance is stopped. |
