import { handleHeapzRequest } from "../../services/heapz.js";
import { HttpService } from "../../services/http-service.js";
import { handleStatzRequest } from "../../services/statz.js";
import { installWebSocketHandoff } from "../../types/websocket-handoff.js";
class ZeroDispatcher extends HttpService {
  id = "zero-dispatcher";
  #getWorker;
  constructor(config, lc, opts, getWorker) {
    super(`zero-dispatcher`, lc, opts, (fastify) => {
      fastify.get(
        "/statz",
        (req, res) => handleStatzRequest(lc, config, req, res)
      );
      fastify.get(
        "/heapz",
        (req, res) => handleHeapzRequest(lc, config, req, res)
      );
      installWebSocketHandoff(lc, this.#handoff, fastify.server);
    });
    this.#getWorker = getWorker;
  }
  #handoff = (_req, dispatch, onError) => {
    void this.#getWorker().then(
      (sender) => dispatch({ payload: "unused", sender }),
      onError
    );
  };
}
export {
  ZeroDispatcher
};
//# sourceMappingURL=zero-dispatcher.js.map
