Router that virtually distributes inference across connected devices in the home.
Go
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package main
// The newline-delimited JSON-RPC 2.0 codec and the bidirectional Peer
// (id-correlation + read pump) are single-sourced in nvpair-shared/jsonrpc. These
// local aliases keep the broker's call sites unchanged. This covers the
// broker's client-facing Codec and the parent-side worker handles, which are
// built on Peer.
import (
"io"
"nvpair-shared/jsonrpc"
)
type (
Message = jsonrpc.Message
RPCError = jsonrpc.RPCError
Codec = jsonrpc.Codec
Peer = jsonrpc.Peer
)
var (
NewCodec = jsonrpc.NewCodec
NewCodecMaxFrame = jsonrpc.NewCodecMaxFrame
NewPeer = jsonrpc.NewPeer
)
// workerFrameBytes is the inbound frame cap for a worker link. Single-sourced
// with every other hop on the same path, because a reply only arrives if all of
// them agree.
const workerFrameBytes = jsonrpc.WorkerFrameBytes
// errPeerClosed is the sentinel a worker handle's Call/RelayRequest returns
// once the child's transport has gone away.
var errPeerClosed = jsonrpc.ErrPeerClosed
// readWriter adapts a child's separate stdout (read) and stdin (write) into the
// io.ReadWriter the shared Codec expects.
type readWriter struct {
io.Reader
io.Writer
}