Server Overview
An EdgeStream server is the central broker for a single message domain — it holds one transport connection, two pipelines (incoming and outgoing), and one subscription manager. Most applications use a single 'bas' server.
What a Server Does
The IServer is the orchestration hub for a logical message domain. When a message arrives from the transport, the server receives raw bytes, runs them through the incoming pipeline, and delivers the processed envelope to subscribers. When the app calls send(), the server runs the outgoing pipeline and then calls transport.send().
| Component | Type | Role |
|---|---|---|
transport | ITransport | Network connection — receives/sends raw bytes |
incomingPipeline | IPipeline | Processes received messages hook-by-hook |
outgoingPipeline | IPipeline | Processes outgoing messages hook-by-hook |
subscriptionManager | ISubscriptionManager | Routes processed envelopes to subscriber callbacks |
Server Types
Servers are typed as 'bas' (BizFirstGO Application Server) or 'chat'. The type is informational — it can be used to differentiate pipeline configurations for different message domains:
type ServerType = 'bas' | 'chat';
Server Interface
export interface IServer {
readonly id: string; // e.g., 'bas', 'chat-server'
readonly type: ServerType; // 'bas' | 'chat'
readonly status: TransportStatus; // connection status
readonly transport: ITransport;
readonly incomingPipeline: IPipeline;
readonly outgoingPipeline: IPipeline;
readonly subscriptionManager: ISubscriptionManager;
start(): Promise<void>; // connects transport, begins message processing
stop(): Promise<void>; // disconnects transport, cleanup
send(topic: string, body: unknown): Promise<void>; // outgoing message
}
Server Registration Flow
registerServer(registration)
Call edgeStream.registerServer({ id, type, url, transportConfig }). The facade creates a transport from config and instantiates a Server.
Add Hooks
Get the server with edgeStream.server('bas') and add hooks to incomingPipeline and/or outgoingPipeline.
Subscribe
Register subscriber callbacks via edgeStream.subscribe(serverId, topic, callback).
edgeStream.start()
Calls server.start() on all registered servers. Transport connects; the server begins processing messages.
Single Server Setup (Typical)
import { createEdgeStream, NormalizationHook } from 'edge-stream-js';
import { HookActivityLogger } from 'observability-hooks-js';
const stream = createEdgeStream({ logLevel: 'info' });
// Register one server for the entire application
stream.registerServer({
id: 'bas',
type: 'bas',
name: 'BizFirst Application Server',
url: '/hubs/edge-stream',
transportConfig: {
type: 'signalr',
url: '/hubs/edge-stream',
accessToken: authService.getToken,
reconnect: { maxAttempts: 0, initialDelayMs: 1000, maxDelayMs: 30000, backoffMultiplier: 2 }
}
});
const server = stream.server('bas')!;
server.incomingPipeline.addHook(new HookActivityLogger());
server.incomingPipeline.addHook(new NormalizationHook());
await stream.start();
'bas' server handles all messages. Use multi-server patterns only when you need separate transport configurations, different pipeline setups, or isolated subscription namespaces for distinct message domains.