25 symbols from @neontechspace/fluxerly
Functions#
fileSessionStore #
Create a Session that keeps each shard's snapshot in its own file, shard-ID.json, inside one directory
Pass it as sharding so a restart within Fluxer's 60-second window resumes instead of starting new sessions. Use a directory that only the bot's account can read, outside version control, because each file holds a session ID that lets the bot's token resume that session. The store never logs snapshot contents
fileSessionStore(directory: string | URL): SessionStorefileSessionStore(
directory: string | URL
): SessionStoreParameters
directory-
string | URL
- Returns
SessionStore
A relative path resolves against the current working directory when the store is created, and a URL must use the
file: scheme. An empty path or another URL scheme throws Configuration.
The store creates nothing until the first save. Each save creates the directory when missing, with mode 0700, writes
the snapshot to a new temporary file with mode 0600 in that directory, flushes it to disk and renames it over the
shard's file, so a crash never leaves a partly written snapshot and the previous file stays until the rename. A failed
save removes its temporary file. Windows ignores these modes, so there the directory's access control list decides
who can read the files.
Load returns undefined when the shard has no file. It returns the parsed file without checking its fields, so the SDK
ignores a malformed or outdated snapshot with a lifecycle Warn. A file that is not valid JSON
rejects with an Error that names the file but not its contents, and other file system failures reject with their
Node.js error. The SDK logs those rejections as lifecycle or lifecycle and
continues, as Session describes.
Separate processes must use separate directories unless their shard IDs never overlap
import { createClient, fileSessionStore } from "@neontechspace/fluxerly"
export function resumableClient(token) {
return createClient({ token, sharding: { totalShards: "auto", sessions: fileSessionStore("sessions") } })
}
import { createClient, fileSessionStore } from "@neontechspace/fluxerly"
export function resumableClient(token: string) {
return createClient({ token, sharding: { totalShards: "auto", sessions: fileSessionStore("sessions") } })
}
Variables#
supervisor#
Run a fixed group of local Node.js child processes, each with its own client and assigned shards
Use create to validate the assignments, then start to launch the children. Each child entry module must call supervisor to create and run its client
const supervisor: SupervisorToolsThe start method waits for assignment and configuration acknowledgements, not gateway READY.
Use wait for all-child READY, and wait to wait until this supervisor's children have exited.
The status method returns a frozen local report with the latest gateway state received from each current child.
Those states are separate observations, not an atomic health check across processes
Fresh gateway Identify sends require a parent permit and are spaced by at least one second, unless identify paces them.
Identify authenticates a new session, while Resume reuses an earlier gateway session.
Session Resume sends do not need a permit.
A permit stays outstanding until the child confirms the send or cancels before sending.
A stalled child is stopped and must exit before another permit is issued, after a full spacing interval.
The child helper receives a stop signal.
A parent stop does not wait for an uncooperative configure promise or start its client afterward
The parent can forcibly terminate only children it started after the graceful deadline, and still waits for their exit.
No process signal handlers are installed.
Child output follows child: Lines are forwarded with a child label by default, and inherit or ignore can be chosen instead.
A crashed child restarts by default, up to three times in a row with exponentially increasing delays. Set restart to false to turn this off.
The child, args and exec options affect child launch but are omitted from status and failures.
With total "auto" and processes or shards, the plan is sized at start. Each child sends its client diagnostics, which status includes.
Children keep resumable sessions through client.
The children share Fluxer's limits per bot account through the parent. When one child is rate-limited globally, the parent
holds the other children's REST requests until the same time. Member requests from all children share one count of 12 in
any 11 seconds, and a members request past it fails at once with reason rate and retry.
A child that gets no answer from the parent within one second counts only its own member requests and logs
supervisor once. Per-route REST rate limits stay per child, and other processes using the same
token are not counted
import { supervisor } from "@neontechspace/fluxerly"
export const workers = supervisor.create({
entry: "/srv/bot-worker.js",
totalShards: 2,
assignments: [
{ id: "one", shardIds: [0] },
{ id: "two", shardIds: [1] },
],
})
import { supervisor } from "@neontechspace/fluxerly"
export const workers = supervisor.create({
entry: "/srv/bot-worker.js",
totalShards: 2,
assignments: [
{ id: "one", shardIds: [0] },
{ id: "two", shardIds: [1] },
],
})
Interfaces#
IdentifyCoordinator #
Coordinates Identify commands for shards that start new sessions, so several processes serving one bot can respect Fluxer's shared Identify budget
Creation copies the permit function, bound to its object, and later changes to the object have no effect. Clients that a local supervisor starts cannot set one, because the supervisor paces their Identify commands. Pass the coordinator to the supervisor option identify instead, and the supervisor consults it for every child
interface IdentifyCoordinatorpermit#
Resolve when the shard may send Identify now
The SDK calls this once per new-session attempt and sends Identify as soon as the promise resolves, without spacing of its own, so pace permits within Fluxer's budget of 300 Identify commands per source IP address in each 60-second window. Only one permit per client is outstanding at a time, so a slow permit delays this client's other shards. The wait counts against the startup deadline during startup and against the recovery attempt timeout during recovery. The signal aborts when the attempt ends first, for example on timeout or shutdown, so resolve or reject promptly then. A rejection or thrown error fails that connection attempt: The SDK logs the error in full at Error with code lifecycle and retries like a transient connection failure, so repeated rejection can end startup with a Connection whose cause is the rejection
permit(
shardId: number,
totalShards: number,
signal: AbortSignal
): Promise<void>permit(
shardId: number,
totalShards: number,
signal: AbortSignal
): Promise<void>Parameters
totalShards -
The plan's total shard count, useful for a bucket key such as
shardmodulo a concurrencyId number signal-
Aborted when the SDK no longer needs this permit
AbortSignal
- Returns
Promise<void>
SessionSnapshot #
The resumable state of one shard's gateway session, saved at shutdown and offered again at the next startup
It holds the session ID, which lets the bot's token resume the session, so store it as carefully as other secrets
interface SessionSnapshotresume#Url -
Gateway URL the session connected to
Fluxer publishes no separate resume URL, so this is the discovered gateway endpoint. A loaded snapshot is used only when it matches the endpoint the new client discovers
string saved#At -
Wall-clock time the snapshot was taken, in Unix epoch milliseconds, after the session's socket closed
number
SessionStore #
Persist resumable gateway sessions across restarts
Fluxer retains a disconnected session for 60,000 ms, so a process that restarts within that window can Resume and receive the dispatches it missed, subject to Fluxer's replay limits. Creation copies both functions, bound to their object. Resumable snapshots are saved only during shutdown, after each shard's socket has closed, never while a session is live and not after a permanent connection failure. Before resuming a loaded snapshot, the SDK replaces it with a used copy whose session is empty, so a crash leaves no resumable snapshot and each snapshot is resumed at most once. A saved session closes with private-use code 4000 to preserve Resume. Without persistence, intentional final closure uses 1000, which destroys the session
interface SessionStoreload#
Return the snapshot saved for this shard, or undefined when none exists
The SDK calls this once per shard at the first connection attempt after discovery, and allows 5,000 ms, within the startup deadline. A snapshot older than 60,000 ms, saved more than 5,000 ms in the future, malformed, already marked as used, for a different gateway endpoint or for a plan with a different total is ignored and logged at Warn with code lifecycle. A rejection, thrown error or timeout is logged in full at Error with code lifecycle. Either way the shard starts a new session, so load problems never fail startup. If Fluxer no longer holds the session, Resume fails and the shard starts a new session as in any recovery. Partial replay can update caches before RESUMED. A fallback to Identify clears that shard's cached communities and dependent resources, then clears reads cached during the wait again at READY. A successful Resume retains the replay
load(shardId: number): Promise<SessionSnapshot | undefined>load(shardId: number): Promise<
SessionSnapshot | undefined
>Parameters
shardId -
The local shard starting up
number
- Returns
Promise<SessionSnapshot | undefined>
save#
Store a snapshot for this shard
The SDK calls this during shutdown for each shard that holds a resumable session, after its socket has closed and before shutdown completes, and allows each call 5,000 ms. Shutdown waits for these calls, then continues regardless of the outcome. At startup, after load returns a resumable snapshot, the SDK also calls this once with a copy whose session is empty, with the same time limit as load. The shard resumes only after that call succeeds, and otherwise starts a new session. A rejection, thrown error or timeout is logged in full at Error with code lifecycle
save(shardId: number, snapshot: SessionSnapshot): Promise<void>save(
shardId: number,
snapshot: SessionSnapshot
): Promise<void>Parameters
shardId -
The local shard the snapshot belongs to
number snapshot-
The frozen resumable state, or at startup the used copy with an empty
sessionId SessionSnapshot
- Returns
Promise<void>
ShardRecoveryDiagnostic #
Connection-attempt snapshot for one shard, a gateway connection owned by this client
Recovery means reconnecting after the shard has previously established a session. Endpoint, session credentials and provider failure details are excluded
interface ShardRecoveryDiagnosticattempt#-
One-based connection attempt number for this shard's managed run, counting startup and later recovery
During a retry delay, identifies the attempt that ended, not the next attempt
number phase#-
Whether this attempt belongs to initial startup or established-session recovery
"startup" | "recovery" retry#Delay Ms -
Scheduled retry wait in milliseconds, or null while the current attempt is not waiting
This is not a remaining countdown
number | null
ShardState #
Frozen connection-state snapshot for one gateway shard owned by this client
Use client to inspect local connections rather than the health of other processes or the whole bot. An explicit plan keeps its shards for the client's lifetime. A client without sharding options reports shard ID zero. An automatically sized client reports no shards until its first connect has chosen the plan. Both report the new plan's shards after they move to a larger plan
interface ShardStategateway#Latency Ms -
Latest current-connection heartbeat round trip in milliseconds, or null when no measurement is current
number | null recovery#-
Current safe connection attempt or retry snapshot, or null when this shard is not attempting or waiting
ShardRecoveryDiagnostic | null session#Epoch -
Identifies this shard's current gateway session within the client
It is 0 until the shard's first new session and gets a new value, never used before by this client and larger than every earlier one, each time the shard starts a new session, including the shards of a larger plan after a move. A Resume, which replays every missed event, keeps it, and so does resuming a saved session after a restart, so a process that resumes a saved session reports 0 until that shard next starts a new session. A changed value means the events of that shard's communities between the two sessions may have been missed. Fluxer then sends each of those communities again as a
guildevent, and a community that is unavailable sendsCreate guildinstead. This is the shard's current value, which can already be newer than the session of an event a handler is still processing, because events wait in each handler's queue. To tell which session an event belongs to, compareDelete Event, which keeps the value from when the client accepted the eventContext .session Epoch number state#-
Current connection status for this shard
ConnectionState
ShardingOptions #
Divide the bot's community events among gateway connections called shards
Set this when the bot needs more than one gateway connection or this client should own only part of a shared shard plan. One client can own several shards within one process. Separate processes use separate clients
interface ShardingOptionsEvery process serving the same bot must use the same total and avoid overlapping ownership.
Omit shard to own every ID from zero through total minus one
Creation validates the plan and copies the supplied IDs in order without changing caller input.
Invalid plans fail creation with Configuration. An explicit plan cannot change during the client's lifetime.
An automatic plan moves to a larger one while the client runs when Fluxer closes a shard with 4011 (sharding required),
and so does the single shard of a client created without sharding settings
Shard zero receives direct-message gateway traffic. Include it when this client must receive direct messages. The SDK does not coordinate other processes unless identify supplies a coordinator
With total set to 1, session startup sends no shard tuple in the gateway Identify command.
Default-API and native clients accept the same plan. Native validation and copying happen when the creation Effect runs
identifyoptional#-
Coordinate new-session Identify commands with other processes, for example through a shared lock service
The coordinator then owns pacing: The SDK waits for permit before each Identify and adds no spacing of its own. Resume never waits for it. See
IdentifyCoordinator IdentifyCoordinator refilloptional#Caches -
Whether a shard that resumes a session loaded from sessions refills the enabled community, role and channel caches through REST, default true
Fluxer calls a community a guild. Resume replays missed dispatches but sends no fresh community snapshot, so without the refill those caches contain only observations from replay, later events and requests. Once every shard is ready, the SDK lists the bot's communities and fetches each one on a resumed shard, one request at a time, so application requests keep the other REST slots and every request respects rate limits. It logs
lifecyclewhen done, at Warn when communities failed or the refill stopped early. A community list page that does not move past the previous one stops the refill instead of paging forever. Set false to skip the refill, for example for a bot that reads no cache.cache Refill booleanDefault
truetrue sessionsoptional#-
Keep resumable sessions across process restarts, so a restart within Fluxer's 60-second resume window can Resume instead of starting new sessions
A fallback to a new session clears any partial restored replay from that shard's community caches and dependent resources. A successful Resume retains it. See
SessionStore SessionStore shardoptional#Ids -
Immutable non-empty local IDs, each unique integer from 0 through
totalminus oneShards Omit to own every ID in ascending order. Automatic sizing requires omission
readonly number[] total#Shards -
Immutable total gateway shards for this bot, an integer from 1 through 16,384 shared by every process serving it
Fluxer closes a shard with
4011(sharding required) when it serves more than 2,500 communities, and with an explicit total that closure ends the client with aConnection. The value "auto" lets this client size the plan itself and own every shard, as the sharding value "auto" does, while keeping identify and sessions availableError number | "auto"
Supervisor#
Parent that starts and stops child processes for one fixed set of local shards
Methods start their asynchronous work when called and return ResultAsync for expected failures. Unexpected defects reject with Sdk instead of returning Err, and a throwing wait option or signal getter uses code application with the thrown value as its cause. Creating this parent starts no child. Call shutdown to release its owned processes
interface Supervisorshutdown#
Ask owned children to stop and return Ok only after their processes exit
After shutdown, force-terminate an owned child that has not exited, then keep waiting for its exit. Concurrent and repeated calls share cleanup. Shutdown before start closes the parent without launching children. Returns Ok even after a supervisor failure or a child's message-channel loss. It does not erase wait's retained failure
shutdown(): ResultAsync<void, never>- Returns
ResultAsync<void, never>
start#
Start the configured children and return Ok when each child accepts its shard assignment and finishes configure
This is setup completion, not gateway readiness. Use wait to observe connected gateway sessions. Concurrent calls share startup. Calling again does not create extra children or await replacement startup. Failure returns Supervisor only after owned processes exit. Start during or after shutdown returns reason closed. With total "auto" it first counts the bot's communities, and a failed count returns reason shard. If a child remains alive after losing its message channel for shutdown, pending startup fails with closed after cleanup
start(): ResultAsync<void, SupervisorError>start(): ResultAsync<
void, SupervisorError
>- Returns
ResultAsync<void, SupervisorError>- Fails with
status#
Return one immutable safe local status snapshot without child output, environment, arguments or paths
status(): SupervisorStatus- Returns
SupervisorStatus
waitForClose #
Wait until the supervisor's lifetime ends and its owned child processes have exited
Returns Ok after normal shutdown or Err with the retained Supervisor after failure, even on a later call. Does not start or stop the supervisor. Calling before start waits until a later shutdown or failure
waitForClose(): ResultAsync<void, SupervisorError>waitForClose(): ResultAsync<
void, SupervisorError
>- Returns
ResultAsync<void, SupervisorError>- Fails with
waitForReady #
Return Ok when every current child has reported its aggregate gateway state as Connected
Start the supervisor first. This observes reports, not simultaneous cross-process health or lasting readiness. Losing a child's message channel clears its readiness immediately. A later call waits for current readiness again. A signal returns Cancelled only for this wait and never stops or restarts a child. An already-aborted signal takes precedence even when the children are ready. A malformed signal returns Configuration with field signal without starting observation. Unknown option keys return Configuration before observation, with a suggested name when one is close. An idle, stopping or closed supervisor returns Supervisor with reason closed. A failed supervisor returns its retained failure
waitForReady(options?: SupervisorWaitOptions): ResultAsync<
void,
ConfigurationError | SupervisorError | CancelledError
>waitForReady(
options?: SupervisorWaitOptions
): ResultAsync<
void,
| ConfigurationError
| SupervisorError
| CancelledError
>Parameters
optionsoptional-
SupervisorWaitOptions
- Returns
ResultAsync< void, ConfigurationError | SupervisorError | CancelledError >ResultAsync< void, | ConfigurationError | SupervisorError | CancelledError >
SupervisorAssignment #
Gateway connections assigned to one child process by its parent supervisor
A shard is one gateway connection responsible for a portion of the bot's community events. The helper copies and freezes this assignment before creating the child client
interface SupervisorAssignmentSupervisorAssignmentOptions #
Name and shard IDs for one Node process that the supervisor starts and stops
Unknown option keys fail with Configuration, with a suggested name when one is close
interface SupervisorAssignmentOptionsid#-
Unique nonblank local identifier, at most 128 characters, shown in lifecycle failures and status snapshots
string
SupervisorChildContext #
Client and fixed shard assignment available to configure before the helper starts the gateway connection
interface SupervisorChildContextassignment#-
Fixed assignment for this child process
It cannot be changed during this run
SupervisorAssignment
SupervisorChildDiagnostics #
One diagnostics snapshot a child sent to its parent: Gateway latency and shard states, REST queue use, cache use and running counters, as its client's diagnostics method returns them
interface SupervisorChildDiagnosticsclient#-
The child client's diagnostics at the time it sent them
ClientDiagnostics received#At -
Parent wall-clock time the snapshot arrived, in Unix epoch milliseconds
An old value means the child stopped reporting
number
SupervisorChildOptions #
Bot credentials, client settings and setup callback for a JavaScript module launched by a supervisor
Unknown option keys fail with Configuration before waiting for the parent, with a suggested name when one is close
interface SupervisorChildOptionsclientoptional#Options -
Every client setting except token is read by property name and copied before configure, including inherited and non-enumerable properties
The supervisor assigns the shards, so sharding accepts only sessions. Runtime validation rejects a token, a shard plan or identify coordinator in sharding, and any other own key that is not a client option, with
ConfigurationError & Omit<ClientOptions<undefined>, "token" | "sharding"> & { readonly sharding?: SupervisorChildSharding }& Omit< ClientOptions<undefined>, "token" | "sharding" > & { readonly sharding?: SupervisorChildSharding } configure#-
Register subscriptions and local application behavior before the helper calls
client.run Return when setup is finished, not when the bot stops. Do not call
client, connect or shutdown here. A thrown error, rejected promise or returned Err rejects.run childwith.run SdkcodeDefect application, whose cause is an.defect Applicationwith source "supervisor child configure" and the original value as its cause. A parent stop can finishError childwithout waiting for this promise. Setup must check.run contextto avoid continuing afterward.signal (context: SupervisorChildContext) => unknown(context: SupervisorChildContext) => unknown token#-
Bot token for the client created by
child, such as.run process.env .FLUXER_ BOT_ TOKEN The parent assignment does not supply this credential. A missing or blank value fails
childwith.run Configurationonce the assignment arrives, asError createdoes, and the parent sees the child fail during configurationClient string | undefined
SupervisorChildSharding #
Sharding settings a supervised child may add to the shards its parent assigns
interface SupervisorChildShardingsessionsoptional#-
Keep this child's resumable sessions across process restarts, as the client option
shardingdoes.sessions A deploy that stops the supervisor and starts it again within Fluxer's 60-second resume window then resumes each shard instead of starting a new session. Resumable snapshots are saved only when the child shuts down normally, so a restart after a crash starts new sessions. The child saves while it shuts down, so saves must finish within the supervisor option
shutdown, after which the parent force-terminates the child. SeeTimeout Ms SessionStore SessionStore
SupervisorChildStatus #
Frozen snapshot of one child assignment and its current process, without launch settings or child output
interface SupervisorChildStatusassignment#-
Immutable assignment retained by this supervisor
SupervisorAssignment connection#State -
Last aggregate gateway connection state reported by the current child process after configuration
Null before its first accepted report, after exit or when IPC is unavailable. Reports from different children are not simultaneous
ConnectionState | null diagnostics#-
Latest client diagnostics the current child process sent, or null before its first snapshot, after exit or when IPC is unavailable
A running child sends one when it finishes configuration and then every
diagnosticsInterval Ms SupervisorChildDiagnostics | null generation#-
Fork attempts for this assignment, starting at zero before startup and incrementing even if a fork fails
number id#-
Stable child identifier from the original assignment
string pid#-
Current owned child process ID, or null before a process starts or after verified exit
number | null restarts#-
Replacement attempts used from this child's current budget, including a replacement waiting for its delay
A restart that follows a healthy run of
healthycounts from one againReset Ms number state#-
Current local lifecycle state
SupervisorChildState
SupervisorFileUrl #
File URL identifying the JavaScript module to run in each child process
A Node URL object satisfies this interface without requiring DOM types in default-API TypeScript consumers
interface SupervisorFileUrlSupervisorIdentifyOptions #
Space out new gateway session starts across the children owned by one supervisor
A new gateway Identify command starts a session. Resuming an existing session does not use this spacing. The parent waits for a child to confirm its send before granting the next permit. Without a coordinator this does not coordinate another supervisor or an application-owned client. Unknown option keys fail with Configuration, with a suggested name when one is close
interface SupervisorIdentifyOptionscoordinatoroptional#-
Share Fluxer's Identify budget with other supervisors and clients, for example across several hosts, through the same
Identifya client accepts inCoordinator sharding.identify Before each grant the parent calls permit with the child's shard ID, the supervisor's total shard count and a signal, and grants the child only after the promise resolves. The coordinator then owns pacing, so the parent adds no spacing of its own. The signal aborts when the child no longer needs the permit, for example when its connection attempt times out, it exits or the supervisor stops. A rejection or thrown error is logged in full at Error with code
supervisor, and the child retries its connection attempt as after a network failure. Creation copies the permit function, bound to its object.identify Permit Failed IdentifyCoordinator
SupervisorOptions #
Plan for running bot gateway connections in separate local Node processes
The supervisor is a parent process that starts, monitors and stops its child processes. Use it when separate processes are needed. A client can own multiple shards without a supervisor. Each child module must call supervisor from its chosen public entry point. Creation validates and copies the launch settings without starting a process. Default-API creation runs immediately. Native creation copies settings when its Effect runs
interface SupervisorOptionsChoose the child processes with exactly one of assignments, processes or shards.
With processes or shards the supervisor splits the shards into contiguous blocks of almost equal size, one
block per child, and names the children process-0, process-1 and so on.
With total set to "auto" the supervisor sizes the plan at start as a client with sharding "auto" does, from the
number of communities the bot is in. Communities are what the API calls guilds.
Assignments stay fixed across replacements. Without an identify coordinator, this supervisor does not coordinate other parents.
Its children share a global rate-limit pause and the count of member requests through it, while per-route REST rate
limits stay per child
argsoptional#-
Program arguments for every owned child, at most 64 strings of at most 4,096 characters each
readonly string[]Default
[][] assignmentsoptional#-
One to
totalfixed child assignments, with unique IDs and no overlapping shard IDsShards Unassigned shards remain application-owned. Cannot be combined with processes or
shardsPer Process readonly SupervisorAssignmentOptions[] childoptional#Environment -
Up to 64 explicit string environment overrides copied over the inherited environment at creation
Keys use ASCII letters, digits and underscores, starting with a letter or underscore. Values have at most 4,096 characters. The parent retains this launch snapshot, including any credentials supplied there, until owned children exit. Status and errors do not contain these settings
Readonly<Record<string, string>> childoptional#Output -
How child standard output and error reach this process
"inherit" | "prefix" | "ignore"The default, prefix, forwards each child line through this process in the format of the stream it goes to. Default-API children log JSON with no color, unless FLUXERLY_LOG_FORMAT or FLUXERLY_LOG_COLOR is set in the child environment. An Effect API child sends its records to Effect's logger unless its
loggingoption is set, so set that option to json to forward structured records. In pretty format each SDK record prints as a readable line and each line gets a label: [shard N] for a child owning one shard, otherwise [child id]. Other text keeps its content behind the label. In json format the output stays valid JSON Lines: A child's SDK record gains a.format fieldsentry, another JSON object passes through unchanged, and other text becomes a.child supervisorrecord. Each stream decides on its own, so with a terminal on standard output and standard error redirected to a file, standard output shows readable lines and the file receives the child's records with their level, code and fields. Lines longer than 262,144 characters are truncated with a marker, and child output pauses while this process's output applies backpressure. Exit handling waits up to one second after a child exits for its output to drain. A failed read of a child stream logs.child Output supervisorat Warn and stops forwarding that stream.output Failed The value inherit shares this process's streams without labels, and ignore discards child output
Default
"prefix""prefix" diagnosticsoptional#Interval Ms -
How often each running child sends its client diagnostics to the parent, in milliseconds, an integer from 1,000 through 2,147,483,647
A child also sends one snapshot as soon as it finishes configuration. See
SupervisorChild Status numberDefault
50005000 entry#-
Absolute module path string or file-URL object passed to every Node child-process fork
A file-URL string is not accepted
string | SupervisorFileUrl execoptional#Argv -
Node executable arguments for every owned child
Omit to copy the parent's
process. At most 64 strings of at most 4,096 characters each. The SDK's development-only fluxerly-source condition is removed.exec Argv readonly string[] identifyoptional#-
Parent-side fresh-Identify pacing shared by these children, or a coordinator shared with other processes
SupervisorIdentifyOptions instanceoptional#-
Fluxer instance for the community count when
totalis "auto", as the client option instanceShards Rejected otherwise
InstanceOptions loggingoptional#-
Records for the automatic plan, child spawn, exit with code and signal, crash, restart and refused Identify permits, in the supervisor log category
A missed startup deadline, a forced termination and an unconfirmed Identify grant are each logged before the supervisor acts on them. Accepts the same settings as client logging. Default output prints these records at Info and higher. The native supervisor sends them to the Effect logger of the context that creates it unless a sink or format is set
LoggingOptions processesoptional#-
Number of child processes that share every shard, an integer from 1 through 16,384
With a numeric
totalit can be at mostShards total. With "auto", a plan with fewer shards than processes starts one process per shardShards number restartoptional#-
Replacement policy for unexpected local child exits
Omit it to restart with the defaults of
Supervisor, or set false so that one unexpected exit stops the whole supervisorRestart Options false | SupervisorRestartOptions shardsoptional#Per Process -
Shards per child process, an integer from 1 through 16,384
The last process owns the remainder when the total does not divide evenly
number shutdownoptional#Timeout Ms -
Time allowed for an owned child to exit after a stop request, in milliseconds, before the parent force-terminates it
A positive safe integer no greater than 2,147,483,647. Shutdown still awaits the process exit, which can take longer. A stopping child first lets running handlers and REST requests finish for up to this time minus one second, as the client shutdown option
draindoes, and keeps that second to close its connections. IPC is Node's parent-child message channel. If a current child loses IPC, it has this long to exit naturally. If that window expires, the supervisor fails with closed and force-terminates that child without a second grace period. Other owned children receive their normal stop request and grace periodMs numberDefault
50005000 startupoptional#Timeout Ms -
Time allowed for each child to receive its assignment and finish configure, in milliseconds, including replacement children
This does not wait for the gateway READY event that establishes a connected session. With
total"auto" the community count before the first child starts has its own deadline of the same length. A positive safe integer no greater than 2,147,483,647. Timeout fails the supervisor, which stops its children and awaits their exitShards numberDefault
3000030000 tokenoptional#-
Bot token used only to count the bot's communities when
totalis "auto", such asShards process.env .FLUXER_ BOT_ TOKEN Children still receive their own token through
supervisor. Required with "auto" and rejected otherwise.child .run string total#Shards -
Total gateway shard count for this bot, an integer from 1 through 16,384
Other processes serving it must use the same total. The value "auto" counts the bot's communities once, at start, by paging GET /users/@me/guilds within
startup, and uses one shard per 2,000 communities, from 1 through 16,384 shards. The count needs the token option, and it works only with processes orTimeout Ms shards, because fixed assignments need a known total. A failed count fails start withPer Process SupervisorreasonError shard, whose cause is theCount Authentication,Error Rate,Limit Error ConnectionorTimeout Error Connectionof the count. Until the count completes, status lists no children. Restarts keep the plan. When Fluxer closes a child's shard withError 4011(sharding required) because the bot outgrew the plan, the supervisor stops every child, counts again and starts children for a larger plan, as a client with sharding "auto" does, logging asupervisorWarn record. Events sent during the move are missed. After 3 moves within an hour, or at 16,384 shards, a further.resharded 4011fails the supervisor with reason closed insteadnumber | "auto" transportoptional#-
HTTP implementation and User-Agent for the community count when
totalis "auto", as the client option transportShards Rejected otherwise
TransportOptions
SupervisorRestartOptions #
Restart a child process after it exits, unless the supervisor has begun shutdown or failed
Restart is on by default with the defaults below. The supervisor option restart set to false turns it off. Each child has its own budget of consecutive restarts. A child that ran for healthy after finishing configuration gets its full budget and the first delay back at its next exit, so only a crash loop exhausts the budget. Delays double after each replacement, up to max. Replacement starts only after the previous process exits. This starts a new process. It does not reconnect the client's gateway or recover its session
interface SupervisorRestartOptionshealthyoptional#Reset Ms -
Milliseconds a child must run after finishing configuration for its next exit to start a fresh restart budget, a positive safe integer no greater than 2,147,483,647
The
supervisorrecord then has.restart fieldstrue.budget Reset numberDefault
6000060000 maxoptional#Attempts -
Maximum replacement attempts per child, an integer from 0 through 100
Zero permits no replacement
numberDefault
33 maxoptional#Delay Ms -
Maximum exponential replacement delay in milliseconds, a positive safe integer no greater than 2,147,483,647
numberDefault
3000030000 minoptional#Delay Ms -
First replacement delay in milliseconds, a positive safe integer no greater than
maxDelay Ms numberDefault
10001000
SupervisorStatus #
Immutable safe local snapshot without child paths, arguments, environment or stdio
interface SupervisorStatuschildren#-
One snapshot per child assignment, in assignment order, including children with no current process
Empty with
total"auto" until start has counted the planShards readonly SupervisorChildStatus[] state#-
Current supervisor lifecycle state
SupervisorState
SupervisorTools #
Create a local parent supervisor or run its child module using the default API
interface SupervisorToolschild#-
Child-module helper
Call run inside the module selected by the parent's entry option
{ run(options: SupervisorChildOptions): ResultAsync< void, | ConfigurationError | SupervisorChildError | CancelledError | ConnectError > }{ run( options: SupervisorChildOptions ): ResultAsync< void, | ConfigurationError | SupervisorChildError | CancelledError | ConnectError > }
create#
Validate and copy options now and return an idle supervisor
Invalid options throw Configuration. Unknown keys in parent, assignment, restart and Identify options include a suggested name when one is close. Each option is read once. A throwing option getter throws Sdk with code application and the thrown value as its cause, while another unexpected fault uses sdk. Does not start a process or check whether the entry module can execute. Launch failures are reported by start
create(options: SupervisorOptions): Supervisorcreate(
options: SupervisorOptions
): SupervisorParameters
options-
SupervisorOptions
- Returns
Supervisor
SupervisorWaitOptions #
Cancel one default-API wait call without stopping or restarting the supervisor
Unknown option keys return Configuration before observation, with a suggested name when one is close
interface SupervisorWaitOptionssignaloptional#-
Cancels only this wait
An already-aborted signal cancels without starting, stopping or restarting any child
OperationSignal
Type Aliases#
SupervisorChildState #
Local process state for a fixed child assignment, not its gateway connection state
Running means the child finished configuration. Restarting means a replacement delay is pending
type SupervisorChildState =
| "idle" | "starting" | "running" | "restarting" | "stopping"
| "closed" | "failed"type SupervisorChildState =
| "idle" | "starting"
| "running" | "restarting"
| "stopping" | "closed"
| "failed"SupervisorState #
Local parent-process lifetime state, not the bot's gateway readiness
Running means the children acknowledged their assignment and configuration. Failed can still include live children while cleanup waits for their exit
type SupervisorState =
| "idle" | "starting" | "running" | "stopping" | "closed"
| "failed"type SupervisorState =
| "idle" | "starting"
| "running" | "stopping"
| "closed" | "failed"