Skip to content
BastiGame edited this page Jan 20, 2026 · 4 revisions

Galactic Logo

Getting Started: Bridge

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.


1. Start the Bridge Server

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 bridge

2. Listen to Events (optional)

The bridge outputs various events, which could be used for log outputs, for example.

this.bridge.on("EVENT_NAME", (...) => {
    console.log(...)
})

Events

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.

Clone this wiki locally