Hyperlinkv0.8.0-beta.28

Hyperlink

Hyperlink.verifyConnectionfunctionsrc/Hyperlink.ts:4541
(node: AnyNode, options?: VerifyConnectionOptions): Effect.Effect<
  void,
  NodeUnreachable | UnaddressedNode
>
(node: AnyNode, options: VerifyConnectionDeepOptions): Effect.Effect<
  void,
  ClientVerifyError
>

Verify a node is reachable, eagerly — a fail-fast startup check for a remote Node. Default: one bounded transport probe (tier 1) against the endpoint connect would dial (selectEndpoint, or every endpoint with { all: true }). Fails NodeUnreachable if nothing answers.

With { deep: true }, escalates after transport OK: dials the auto-served NodeStatus over that endpoint. Transport up but RPC silent → ProtocolUnanswered; optional resource key → ServiceNotServed / ServiceNotReady; optional contractHashContractMismatch (F4).

yield* Hyperlink.verifyConnection(Droplet);                          // tier 1
yield* Hyperlink.verifyConnection(Droplet, { timeout: "1 second" });
yield* Hyperlink.verifyConnection(Droplet, { deep: true });          // + NodeStatus RPC
yield* Hyperlink.verifyConnection(Droplet, {
  deep: true,
  resource: Emails.groupId,
  contractHash: Hyperlink.contractHash(Emails),
});
yield* Hyperlink.verifyConnection(Droplet, { all: true });           // every endpoint

Complements connect: connect prevents mis-wiring the client transport; verifyConnection catches a peer that isn't there (or, with deep, isn't speaking RPC / isn't serving the resource you need / has a stale contract).

Source src/Hyperlink.ts:454136 lines
export function verifyConnection(
  node: AnyNode,
  options?: VerifyConnectionOptions,
): Effect.Effect<void, NodeUnreachable | UnaddressedNode>;
export function verifyConnection(
  node: AnyNode,
  options: VerifyConnectionDeepOptions,
): Effect.Effect<void, ClientVerifyError>;
export function verifyConnection(
  node: AnyNode,
  options?: VerifyConnectionOptions & {
    readonly deep?: boolean;
    readonly resource?: string;
    readonly contractHash?: string;
  },
): Effect.Effect<void, ClientVerifyError> {
  const endpoints = verifyEndpointsOf(node, options);
  if (endpoints instanceof UnaddressedNode) {
    return Effect.fail(endpoints);
  }
  const timeout = options?.timeout ?? "3 seconds";
  const deep = options?.deep === true;
  const resource = options?.resource;
  const expectedHash = options?.contractHash;
  return Effect.forEach(
    endpoints,
    (ep) =>
      Effect.gen(function* () {
        yield* probeEndpointReachable(node.key, ep, timeout);
        if (deep) {
          yield* probeEndpointDeep(node.key, ep, timeout, resource, expectedHash);
        }
      }),
    { discard: true },
  );
}