Hyperlinkv0.8.0-beta.28

Node

<Serve extends Layer.Layer<never, any, any>>(
  serve: Serve,
  options?: HttpServerOptions
): Layer.Layer<
  Layer.Success<Serve>,
  Layer.Error<Serve>,
  Layer.Services<Serve> | HttpServer.HttpServer
>
(options?: HttpServerOptions): Layer.Layer<
  never,
  never,
  Hyperlink.ServedHyperlinks | HttpServer.HttpServer
>
<Serves extends ServerServeList>(
  serves: Serves,
  options?: HttpServerOptions
): Layer.Layer<
  Layer.Success<Serves[number]>,
  Layer.Error<Serves[number]>,
  Layer.Services<Serves[number]> | HttpServer.HttpServer
>

A WebSocket RPC server — the httpServer sibling for the browser. Everything a client subscribes to (each resource's status + metrics + logs) rides one multiplexed WebSocket per client, so a dashboard never trips the browser's ~6-connection-per-origin HTTP/1.1 cap that starves streams over plain HTTP. Identical to httpServer in every other way — same serve list, same options, same /health — it just speaks WebSocket instead of HTTP POST. Clients connect with Hyperlink.ws (or Hyperlink.layerProtocol(Hyperlink.protocolWebsocket())); a fleet whose peers also serve over this should add Hyperlink.layerPeerProtocol(Hyperlink.protocolWebsocket).

const Node = Hyperlink.wsServer([Hyperlink.serve(Jobs, jobsImpl)]).pipe(
  Layer.provide(NodeHttpServer.layer(() => createServer(), { port })),
);
export function wsServer<Serve extends Layer.Layer<never, any, any>>(
  serve: Serve,
  options?: HttpServerOptions,
): Layer.Layer<
  Layer.Success<Serve>,
  Layer.Error<Serve>,
  Layer.Services<Serve> | HttpServer.HttpServer
>;
export function wsServer(
  options?: HttpServerOptions,
): Layer.Layer<never, never, Hyperlink.ServedHyperlinks | HttpServer.HttpServer>;
export function wsServer<Serves extends ServerServeList>(
  serves: Serves,
  options?: HttpServerOptions,
): Layer.Layer<
  Layer.Success<Serves[number]>,
  Layer.Error<Serves[number]>,
  Layer.Services<Serves[number]> | HttpServer.HttpServer
>;
export function wsServer(
  servesOrOptions?:
    | Layer.Layer<never, any, any>
    | ServerServeList
    | ReadonlyArray<Layer.Layer<never, any, any>>
    | HttpServerOptions,
  maybeOptions?: HttpServerOptions,
): Layer.Layer<never, any, any> {
  return serverImpl(
    Hyperlink.serverProtocolWebsocket,
    "WebSocket",
    servesOrOptions,
    maybeOptions,
  );
}