{
  "slug": "trio-nursery-start-readiness",
  "version": 1,
  "project": "trio",
  "title": "Trio service startup readiness handshake with nursery.start",
  "description": "The parent awaits nursery.start for a trio.serve_tcp child. The child binds listening sockets, then calls task_status.started(listeners). Only then does the parent receive the listeners and connect to a returned port. The child continues serving after the readiness signal.",
  "config": {
    "design": "sequence-lifelines-ordered-labeled-messages",
    "name": "nursery-start-readiness",
    "style": "clean",
    "palette": [
      "#625b99"
    ],
    "accessibility": {
      "title": "Trio service startup readiness handshake with nursery.start",
      "description": "The parent awaits nursery.start for a trio.serve_tcp child. The child binds listening sockets, then calls task_status.started(listeners). Only then does the parent receive the listeners and connect to a returned port. The child continues serving after the readiness signal."
    },
    "parameters": {
      "participants": [
        {
          "id": "parent",
          "label": "Parent task",
          "description": "Waits for started()",
          "icon": "tabler:code"
        },
        {
          "id": "service",
          "label": "Service child task",
          "description": "Runs trio.serve_tcp",
          "icon": "tabler:server"
        },
        {
          "id": "socket",
          "label": "Listening socket",
          "description": "Bound and listening",
          "icon": "tabler:network"
        }
      ],
      "messages": [
        {
          "from": "parent",
          "to": "service",
          "label": "await nursery.start(serve)"
        },
        {
          "from": "service",
          "to": "socket",
          "label": "Bind and listen"
        },
        {
          "from": "socket",
          "to": "service",
          "label": "Listening sockets ready",
          "kind": "reply"
        },
        {
          "from": "service",
          "to": "parent",
          "label": "started(listeners)",
          "kind": "reply"
        },
        {
          "from": "parent",
          "to": "socket",
          "label": "Connect to returned port"
        },
        {
          "from": "socket",
          "to": "parent",
          "label": "TCP connection established",
          "kind": "reply"
        }
      ]
    }
  },
  "files": {
    "svg": {
      "url": "/diagram-sources/trio-nursery-start-readiness/v1/diagram.svg",
      "sha256": "a67de577a9f12690d79035d639e02160f9536ad88c4b8c48583a691dcf24c322"
    },
    "png": {
      "url": "/diagram-sources/trio-nursery-start-readiness/v1/diagram.png",
      "sha256": "618f31a396a334c2040419f562e4115dbf9bc9d8c8ae5903ac80ca46c022d7d9"
    }
  }
}
