oa_gateway_owp

Module session

Source
Expand description

One WebSocket session: INIT, then PUB / SUB / UNSUB until close.

Binary frames are refused and the socket is closed. A parse error on a text frame is -ERR Illegal-Argument and the session stays up. A failed INIT closes it.

StructsΒ§

  • LiveSub πŸ”’
    One client SUB: the engine key and the task that forwards MSG frames.
  • RouteWarnings πŸ”’
    Unroutable publishes and invalid payloads, tracked separately.
  • SeenRoutes πŸ”’
    Routes this connection has already been warned about.
  • Session πŸ”’
    One accepted WebSocket and the engine handle it publishes through.
  • ViolationWording πŸ”’
    The wording that differs between a violation found in what the producer put on the bus and one found in what xml_baseline conversion produced.

EnumsΒ§

  • Fatal πŸ”’
    End the WebSocket after an -ERR that the spec treats as fatal.
  • Report πŸ”’
    Whether an unroutable publish is worth reporting yet.
  • State πŸ”’
  • Verdict πŸ”’
    What the caller of handle_violations should do with the delivery.

ConstantsΒ§

  • OWP_VERSION πŸ”’
    Protocol version this server speaks. INIT must list it.

FunctionsΒ§

  • cap_notice πŸ”’
    Say when a tracker has stopped naming routes, so a quiet log is not mistaken for a quiet client.
  • deadline_elapsed πŸ”’
    Resolves once deadline passes, or never when it is None (the timeout disabled). Used as one arm of the session select!.
  • err_op πŸ”’
    Builds a -ERR frame. details is the rest of the line when set.
  • handle_init πŸ”’
    Negotiates INIT. Success sends INFO (and +OK when verbose).
  • handle_pub πŸ”’
    Publishes onto the engine. A bad payload is -ERR Invalid-Message and the session stays up.
  • handle_sub πŸ”’
    Subscribes the engine and spawns a forwarder that writes MSG frames.
  • handle_text πŸ”’
    Dispatches one client text frame.
  • handle_unsub πŸ”’
    Aborts the forwarder and unsubscribes. Unknown sid is -ERR.
  • Applies validate’s policy to violations: in Reject mode, sends a -ERR and reports Verdict::Drop; in Warn mode, only logs. Either way the warning is logged once per subscription, via logged.
  • info_payload πŸ”’
    Builds INFO. The service UUID is v5 of the client’s service_id.
  • negotiate πŸ”’
    Checks INIT.versions contains OWP_VERSION and INIT.schema matches when OwpConfig::schema is set.
  • publish_owp πŸ”’
    Maps one PUB onto one or two engine envelopes and publishes them.
  • run πŸ”’
    Runs session until shutdown, close, or a fatal protocol error.
  • send πŸ”’
    Queues op for the writer. A full or closed channel is ignored so a slow client cannot stall the read loop.