Skip to content

Commit a197eb2

Browse files
committed
Address comments
1 parent 5598dd8 commit a197eb2

5 files changed

Lines changed: 24 additions & 23 deletions

File tree

lib/runtime/dispatcher.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class Dispatcher {
4141
*/
4242
handle(conn) {
4343
const state = {
44-
publishers: new Map(), // capability name -> publisher
45-
subscriptions: new Map(), // subId -> { name, subscription }
46-
clients: new Map(), // capability name -> client
44+
publishers: new Map(), // capability name -> Publisher
45+
subscriptions: new Map(), // subId -> { name, Subscription }
46+
clients: new Map(), // capability name -> Client
4747
};
4848

4949
const cleanup = () => {
@@ -104,9 +104,6 @@ class Dispatcher {
104104
case 'unsubscribe':
105105
return this._handleUnsubscribe(conn, id, frame.subId, state);
106106
case 'action':
107-
// Reserved for future Action capability dispatch (planned for
108-
// 2.2.x). Returning a stable code now keeps the wire protocol
109-
// forward-compatible for clients that probe for support.
110107
conn.send({
111108
id,
112109
ok: false,

lib/runtime/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ class Runtime {
9999

100100
/**
101101
* Convenience factory. Defaults to a single {@link WebSocketTransport} on
102-
* port 9000, path `/capability`. Pass `transport` or `transports` to swap or
103-
* add other adapters (HTTP/SSE planned for 2.2.0).
102+
* port 9000, path `/capability`. Pass `transport` or `transports` to swap
103+
* or add other adapters.
104104
*
105105
* @param {object} options
106106
* @param {import('../node.js')} options.node

lib/runtime/registry.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@
2323
*/
2424
class CapabilityRegistry {
2525
constructor() {
26-
this._call = new Map();
27-
this._publish = new Map();
28-
this._subscribe = new Map();
26+
// Per-kind allow-lists. Each map is keyed by ROS name and stores the
27+
// resolved interface type, e.g. `_call.get('/add_two_ints')` returns
28+
// `'example_interfaces/srv/AddTwoInts'`. Looked up at dispatch time
29+
// by Dispatcher.resolve(kind, name).
30+
this._call = new Map(); // ROS service name -> srv type
31+
this._publish = new Map(); // ROS topic name -> msg type
32+
this._subscribe = new Map(); // ROS topic name -> msg type
2933
}
3034

3135
/**
@@ -47,7 +51,7 @@ class CapabilityRegistry {
4751
*
4852
* The rich form is accepted today but the runtime only consumes
4953
* `type`; additional fields are reserved for forward-compatibility
50-
* (e.g. QoS metadata in 2.4.0). Snapshots via {@link list} always
54+
* (e.g. future QoS metadata). Snapshots via {@link list} always
5155
* return the canonical `{ name: typeName }` form regardless of
5256
* which form was used here.
5357
*
@@ -89,7 +93,7 @@ class CapabilityRegistry {
8993
*
9094
* Always returns the canonical shorthand form
9195
* (`{ [name]: typeName }`) regardless of how `expose()` was called.
92-
* Useful for introspection / OpenAPI export (planned for 2.3.0).
96+
* Useful for introspection and future OpenAPI export.
9397
*/
9498
list() {
9599
return {

lib/runtime/transport.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const EventEmitter = require('events');
1313
/**
1414
* @typedef {Object} CapabilityFrame
1515
* @property {string|number} [id] - Caller-assigned request id (echoed in reply).
16-
* @property {'call'|'publish'|'subscribe'|'unsubscribe'|'action'} [kind] - Request kind (C→S only). `'action'` is reserved (returns `code: 'not_implemented'` until 2.2.x).
16+
* @property {'call'|'publish'|'subscribe'|'unsubscribe'|'action'} [kind] - Request kind (C→S only). `'action'` is reserved and currently returns `code: 'not_implemented'`.
1717
* @property {string} [capability] - Capability name, e.g. `/cmd_vel`.
1818
* @property {*} [payload] - Message payload (call request, publish msg, sub event).
1919
* @property {string|number} [subId] - For unsubscribe: id of the original subscribe.
@@ -26,17 +26,17 @@ const EventEmitter = require('events');
2626
/**
2727
* Per-connection abstraction handed to the runtime by a transport adapter.
2828
*
29-
* The transport owns the wire (WebSocket today; HTTP/SSE planned for 2.2.0)
29+
* The transport owns the wire (WebSocket today; other adapters may follow)
3030
* and exposes each connection as a `Connection` so the runtime can stay
3131
* transport-agnostic. Concrete adapters subclass `Connection` and call
3232
* `this.emit('message', frame)` / `this.emit('close')` as frames arrive on
3333
* the wire, and implement `send(frame)` / `close(code, reason)` to push
3434
* frames back out.
3535
*
36-
* @experimental — the base class shape may grow in 2.2 (e.g. backpressure
37-
* hooks for SSE) and is not part of the SemVer-stable surface for
38-
* third-party adapter authors. The first-party `WebSocketTransport` is
39-
* stable and recommended for production use.
36+
* @experimental — the base class shape may grow (e.g. backpressure hooks)
37+
* and is not part of the SemVer-stable surface for third-party adapter
38+
* authors. The first-party `WebSocketTransport` is stable and recommended
39+
* for production use.
4040
*
4141
* @event Connection#message
4242
* @type {CapabilityFrame}
@@ -74,11 +74,11 @@ class Connection extends EventEmitter {
7474
* 3. Calls `onConnection(conn)` from the start options once per client.
7575
*
7676
* The runtime never speaks to the wire directly — it only consumes the
77-
* Connection event surface. This is the seam that lets us add the HTTP/SSE
78-
* adapter in 2.2.0 without touching the runtime or the SDK.
77+
* Connection event surface. This is the seam that lets future adapters
78+
* (HTTP, etc.) drop in without touching the runtime or the SDK.
7979
*
8080
* @experimental — same forward-compat caveat as {@link Connection}: the
81-
* adapter contract may grow in 2.2 to support new transports. First-party
81+
* adapter contract may grow to support new transports. First-party
8282
* `WebSocketTransport` is stable.
8383
*/
8484
class TransportAdapter {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"docs": "make -C tools/jsdoc",
4141
"docs:gh-pages": "node tools/jsdoc/regenerate-published-docs.js --branch origin/gh-pages --preserve-published",
4242
"docs:gh-pages:full": "node tools/jsdoc/regenerate-published-docs.js --branch origin/gh-pages --full-rebuild",
43-
"test": "nyc node --expose-gc ./scripts/run_test.js && tsd && npm install --no-save electron@34.0.0 && node test/electron/run_test.js",
43+
"test": "nyc node --expose-gc ./scripts/run_test.js && tsd && npm install --no-save electron && node test/electron/run_test.js",
4444
"test-idl": "nyc node --expose-gc ./scripts/run_test.js --idl",
4545
"lint": "eslint && node ./scripts/cpplint.js",
4646
"test:asan": "bash scripts/run_asan_test.sh",

0 commit comments

Comments
 (0)