Gateway control
Gateway control is the Admin view of the running main Gateway cluster. It reads live node state and submits guild reload requests, and it exposes no session, presence, or call payload.
An unanswered Gateway request returns 504 GATEWAY_TIMEOUT. An overloaded or unavailable cluster returns 503 SERVICE_UNAVAILABLE. An invalid Gateway response returns 502 BAD_GATEWAY.
Node statistics object
Seção intitulada “Node statistics object”One snapshot of the Gateway cluster, taken across the nodes the request polled. Every top-level counter except uptime_seconds, node_count, and status is a plain sum over those nodes, including each member of memory. The nodes array reports each polled node on its own.
Structure
Seção intitulada “Structure”| Field | Type | Description |
|---|---|---|
| status1 | string | The aggregate health of the cluster |
| sessions | integer | The connected client Gateway sessions, summed across nodes |
| session_resumes_total | integer | The total number of session resumes, summed across nodes |
| websocket_dispatches_total | integer | The total number of WebSocket dispatches, summed across nodes |
| websocket_dispatch_drops_total | integer | The total number of WebSocket dispatches dropped, summed across nodes |
| guilds | integer | The live guild processes, summed across nodes |
| presences | integer | The tracked presences, summed across nodes |
| calls | integer | The live calls, summed across nodes |
| memory | node memory object | The memory accounting, summed across nodes |
| process_count | integer | The Erlang processes in use, summed across nodes |
| process_limit | integer | The Erlang process ceiling, summed across nodes |
| uptime_seconds2 | integer | The lowest uptime any polled node reported, in seconds |
| node_count3 | integer | The number of nodes the request polled |
| nodes4 | array[gateway node object] | The per-node breakdown (max 1000 entries) |
1 healthy when every polled node reported healthy and degraded when at least one did not
2 The value tracks the most recently started node and drops back whenever any node restarts
3 Includes nodes that did not answer
4 Entries are ordered by node_id ascending. The node that served the request is always polled, so the array is never empty
Example
Seção intitulada “Example”{ "status": "healthy", "sessions": 4820, "session_resumes_total": 1234, "websocket_dispatches_total": 1234567, "websocket_dispatch_drops_total": 123, "guilds": 1913, "presences": 4611, "calls": 12, "memory": {"total": "3221225472", "processes": "1610612736", "system": "1610612736"}, "process_count": 92114, "process_limit": 2097152, "uptime_seconds": 84213, "node_count": 2, "nodes": []}Gateway node object
Seção intitulada “Gateway node object”One entry for each node the request polled, including nodes that did not answer within the 10 second per-node deadline.
Structure
Seção intitulada “Structure”| Field | Type | Description |
|---|---|---|
| node_id1 | string | The name the node reports for itself |
| status2 | string | The health this node reported |
| sessions | integer | The connected client Gateway sessions on this node |
| session_resumes_total | integer | The total number of session resumes on this node |
| websocket_dispatches_total | integer | The total number of WebSocket dispatches on this node |
| websocket_dispatch_drops_total | integer | The total number of WebSocket dispatches dropped on this node |
| guilds | integer | The live guild processes on this node |
| presences | integer | The tracked presences on this node |
| calls | integer | The live calls on this node |
| memory | node memory object | The memory accounting for this node |
| process_count | integer | The Erlang processes in use on this node |
| process_limit | integer | The Erlang process ceiling on this node |
| uptime_seconds | integer | The seconds since this node started |
| cluster_metrics?3 | gateway cluster metrics object | The clustering counters of this node |
1 A node reports its HOSTNAME environment value when that value is a non-blank string, and its Erlang node name otherwise
2 healthy for a node that answered and unavailable for one that did not. A node that did not answer reports null for every counter here and contributes zero to every cluster total
3 Absent for a node that did not answer
A node entry can have further diagnostic members. A client treats a member it does not recognise as absent.
Gateway cluster metrics object
Seção intitulada “Gateway cluster metrics object”How one node sees the Gateway cluster. Every total counts from the moment the node started, so a restart resets it to zero.
Structure
Seção intitulada “Structure”| Field | Type | Description |
|---|---|---|
| gateway_cluster_member_count | integer | The cluster members this node currently counts as alive |
| gateway_cluster_discovery_resolve_failures_total | integer | The times this node failed to resolve its cluster peers |
| gateway_cluster_membership_transitions_total | membership transition counts object | The members this node saw join and leave |
| gateway_node_router_owner_resolutions_total | owner resolution counts object | Where this node routed the work it had to place |
The object can have further diagnostic members. A client treats a member it does not recognise as absent.
Membership transition counts object
Seção intitulada “Membership transition counts object”Structure
Seção intitulada “Structure”| Field | Type | Description |
|---|---|---|
| up | integer | Members that joined the alive set |
| down | integer | Members that left the alive set |
Owner resolution counts object
Seção intitulada “Owner resolution counts object”Structure
Seção intitulada “Structure”| Field | Type | Description |
|---|---|---|
| self | integer | Owner lookups that resolved to this node |
| peer | integer | Owner lookups that resolved to another node |
Node memory object
Seção intitulada “Node memory object”Byte counts for one node, or for every polled node summed together. Each count is a decimal string because a JSON number cannot preserve a 64-bit byte count.
Structure
Seção intitulada “Structure”| Field | Type | Description |
|---|---|---|
| total | string | The total bytes allocated |
| processes | string | The bytes allocated to Erlang processes |
| system | string | The bytes allocated outside Erlang processes |
Guild memory statistics object
Seção intitulada “Guild memory statistics object”Memory and activity for one live guild.
Structure
Seção intitulada “Structure”| Field | Type | Description |
|---|---|---|
| node_id | string | The node that owns the guild process |
| guild_id | ?snowflake | The ID of the guild the process serves, or null when the process state has no guild ID |
| guild_name1 | string | The guild name the process holds in memory |
| guild_icon | ?string | The icon hash the guild process holds in memory, or null when it has none |
| nsfw_level2 | ?integer | The NSFW level resolved from stored guild data, or null when the guild could not be resolved |
| memory3 | string | The bytes the guild process uses, as a decimal string |
| member_count | integer | The number of members the guild process holds |
| session_count | integer | The number of sessions subscribed to the guild process |
| presence_count | integer | The number of presences the guild process tracks |
1 A process whose cached guild data has no name reports Unknown
2 Null for a live process whose guild row could not be loaded and for a process that reports no guild_id
3 The Erlang process memory of the guild process. Entries are ordered by it descending across the whole cluster, with ties broken by guild_id ascending
Voice state count object
Seção intitulada “Voice state count object”Cluster voice state totals, with one grouping by voice region and one by voice server.
Structure
Seção intitulada “Structure”| Field | Type | Description |
|---|---|---|
| total_voice_states1 | integer | The voice states across the whole cluster |
| regions2 | array[region voice state count object] | The counts grouped by voice region (max 1000 entries) |
| servers2 | array[server voice state count object] | The counts grouped by voice server (max 5000 entries) |
1 The sum of the totals each node reported, so it can differ from the sum of the entries in regions or servers
2 Entries are ordered by voice_state_count descending, with ties broken by identifier ascending. An identifier with no voice states is absent from the array, so every entry has a count of at least 1
Example
Seção intitulada “Example”{ "total_voice_states": 318, "regions": [{"region_id": "europe-north", "voice_state_count": 204}], "servers": [{"server_id": "europe-north-server-1", "voice_state_count": 204}]}Region voice state count object
Seção intitulada “Region voice state count object”One entry for each voice region that holds at least one voice state.
Structure
Seção intitulada “Structure”| Field | Type | Description |
|---|---|---|
| region_id | string | The ID of the region the count belongs to |
| voice_state_count | integer | The voice states attributed to the region |
Server voice state count object
Seção intitulada “Server voice state count object”One entry for each voice server that holds at least one voice state.
Structure
Seção intitulada “Structure”| Field | Type | Description |
|---|---|---|
| server_id1 | string | The ID of the server the count belongs to |
| voice_state_count | integer | The voice states attributed to the server |
1 The identifier is unique only inside its region
Get Gateway node statistics
Seção intitulada “Get Gateway node statistics”GET/v1/admin/gateway/statsReturns the node statistics object for the whole Gateway cluster. Requires gateway:memory_stats.
Response
Seção intitulada “Response”| Status | Body | Condition |
|---|---|---|
| 200 | node statistics object | Cluster state was returned |
Side effects
Seção intitulada “Side effects”The operation records one Admin audit entry with action get_gateway_stats, target type gateway, target ID 0, and metadata key node_count.
Rate limit
Seção intitulada “Rate limit”200 requests per minute for each authenticated user, on the admin:lookup bucket.
Get guild memory statistics
Seção intitulada “Get guild memory statistics”GET/v1/admin/gateway/memory-statsReturns the heaviest live guild processes as guild memory statistics objects. Requires gateway:memory_stats.
Query parameters
Seção intitulada “Query parameters”| Field | Type | Description |
|---|---|---|
| limit?1 | integer | The maximum guild processes to return (100-1000, default 100) |
1 The Gateway clamps the value it acts on to 500, and each node contributes at most 100 of its own guild processes. A limit of 1000 returns at most 500 entries
Response body
Seção intitulada “Response body”| Field | Type | Description |
|---|---|---|
| guilds | array[guild memory statistics object] | The guild processes in this response (max 1000 entries) |
Response
Seção intitulada “Response”| Status | Body | Condition |
|---|---|---|
| 200 | response body | The guild processes were returned |
Side effects
Seção intitulada “Side effects”A node that does not answer within 5 seconds contributes no entries, and the request still returns 200.
The operation records one Admin audit entry with action list_guild_memory_stats, target type guild, target ID 0, and metadata keys limit and result_count for the entries in this response.
Rate limit
Seção intitulada “Rate limit”200 requests per minute for each authenticated user, on the admin:lookup bucket.
Get voice state counts
Seção intitulada “Get voice state counts”GET/v1/admin/gateway/voice-state-countsReturns the voice state count object. Requires gateway:memory_stats.
Response
Seção intitulada “Response”| Status | Body | Condition |
|---|---|---|
| 200 | voice state count object | Counts were returned |
Side effects
Seção intitulada “Side effects”The counts cover voice states in guild channels and in calls. A node that does not answer within 10 seconds contributes zero, and the request still returns 200.
The operation records one Admin audit entry with action get_voice_state_counts, target type gateway, target ID 0, and metadata keys total_voice_states, region_count, and server_count.
Rate limit
Seção intitulada “Rate limit”200 requests per minute for each authenticated user, on the admin:lookup bucket.
Reload Gateway guilds
Seção intitulada “Reload Gateway guilds”POST/v1/admin/gateway/reloadsFetches the guild data for the supplied guilds from the database again and sends it to each live guild process and returns how many live guild processes were selected. Requires gateway:reload_all.
JSON body
Seção intitulada “JSON body”| Field | Type | Description |
|---|---|---|
| guild_ids1 | array[snowflake] | The guilds to reload (max 1000 entries) |
1 The field is required. An empty array selects every live guild process on every active node
Response body
Seção intitulada “Response body”| Field | Type | Description |
|---|---|---|
| count1 2 | integer | The number of live guild processes selected for reload |
1 A supplied guild with no live process is skipped, so the value can be lower than the number of IDs sent. An owner node that fails or does not answer within 15 seconds contributes zero
2 Taken when the processes are selected. A selected process whose guild data cannot be fetched is still counted, so the value is an upper bound on the reloads that succeeded
Response
Seção intitulada “Response”| Status | Body | Condition |
|---|---|---|
| 200 | response body | Fluxer started a reload for every selected guild process |
Side effects
Seção intitulada “Side effects”A guild whose owner node cannot be resolved is not counted. Reloads can still be in progress when the response arrives. No guild data is changed.
The operation records one Admin audit entry with action reload_guilds, target type guild, target ID 0, and metadata keys guild_count for the requested guilds and reloaded for the returned count.
Rate limit
Seção intitulada “Rate limit”5 requests per minute for each authenticated user, on the admin:gateway:reload bucket.
Kordyx · Documentação adaptada do Fluxer, sob AGPLv3.Código-fonte e licenças ·Abrir Kordyx ·Aplicativos