[ VM / Service ] Make _registerService and related streams / events public

Change-Id: I243bed9e1f4b3bbcfd232a8c27bf352f55284644
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108366
Reviewed-by: Siva Annamalai <asiva@google.com>
This commit is contained in:
Ben Konyi 2019-07-10 16:07:15 +00:00
parent de2ff7eebb
commit 0de18dce6c
12 changed files with 121 additions and 29 deletions

View file

@ -929,7 +929,7 @@ abstract class VM extends ServiceObjectOwner implements M.VM {
static const kStdoutStream = 'Stdout';
static const kStderrStream = 'Stderr';
static const _kGraphStream = '_Graph';
static const kServiceStream = '_Service';
static const kServiceStream = 'Service';
/// Returns a single-subscription Stream object for a VM event stream.
Future<Stream<ServiceEvent>> getEventStream(String streamId) async {

View file

@ -14,7 +14,7 @@ var tests = <IsolateTest>[
VM vm = isolate.owner;
final serviceEvents =
(await vm.getEventStream('_Service')).asBroadcastStream();
(await vm.getEventStream('Service')).asBroadcastStream();
WebSocket _socket =
await WebSocket.connect((vm as WebSocketVM).target.networkAddress);
@ -45,7 +45,7 @@ var tests = <IsolateTest>[
socket.add({
'jsonrpc': '2.0',
'id': 1,
'method': '_registerService',
'method': 'registerService',
'params': {'service': successServiceName, 'alias': serviceAlias}
});
@ -58,7 +58,7 @@ var tests = <IsolateTest>[
socket.add({
'jsonrpc': '2.0',
'id': 1,
'method': '_registerService',
'method': 'registerService',
'params': {'service': errorServiceName, 'alias': serviceAlias}
});

View file

@ -14,7 +14,7 @@ var tests = <IsolateTest>[
VM vm = isolate.owner;
final serviceEvents =
(await vm.getEventStream('_Service')).asBroadcastStream();
(await vm.getEventStream('Service')).asBroadcastStream();
WebSocket _socket =
await WebSocket.connect((vm as WebSocketVM).target.networkAddress);
@ -43,7 +43,7 @@ var tests = <IsolateTest>[
socket.add({
'jsonrpc': '2.0',
'id': 1,
'method': '_registerService',
'method': 'registerService',
'params': {'service': serviceName, 'alias': serviceAlias}
});

View file

@ -14,7 +14,7 @@ var tests = <IsolateTest>[
VM vm = isolate.owner;
final serviceEvents =
(await vm.getEventStream('_Service')).asBroadcastStream();
(await vm.getEventStream('Service')).asBroadcastStream();
WebSocket _socket =
await WebSocket.connect((vm as WebSocketVM).target.networkAddress);
@ -46,7 +46,7 @@ var tests = <IsolateTest>[
socket.add({
'jsonrpc': '2.0',
'id': 1,
'method': '_registerService',
'method': 'registerService',
'params': {'service': serviceName, 'alias': serviceAlias}
});

View file

@ -14,7 +14,7 @@ var tests = <IsolateTest>[
VM vm = isolate.owner;
final serviceEvents =
(await vm.getEventStream('_Service')).asBroadcastStream();
(await vm.getEventStream('Service')).asBroadcastStream();
expect(vm.services, isEmpty,
reason: 'No service should be registered at startup');
@ -45,7 +45,7 @@ var tests = <IsolateTest>[
socket.add({
'jsonrpc': '2.0',
'id': 1,
'method': '_registerService',
'method': 'registerService',
'params': {'service': serviceName, 'alias': serviceAlias}
});
@ -72,7 +72,7 @@ var tests = <IsolateTest>[
socket.add({
'jsonrpc': '2.0',
'id': 1,
'method': '_registerService',
'method': 'registerService',
'params': {'service': serviceName + '2', 'alias': serviceAlias + '2'}
});
@ -99,7 +99,7 @@ var tests = <IsolateTest>[
socket.add({
'jsonrpc': '2.0',
'id': 1,
'method': '_registerService',
'method': 'registerService',
'params': {'service': serviceName, 'alias': serviceAlias}
});

View file

@ -14,7 +14,7 @@ var tests = <IsolateTest>[
VM vm = isolate.owner;
final serviceEvents =
(await vm.getEventStream('_Service')).asBroadcastStream();
(await vm.getEventStream('Service')).asBroadcastStream();
expect(vm.services, isEmpty,
reason: 'No service should be registered at startup');
@ -44,7 +44,7 @@ var tests = <IsolateTest>[
// Registering first service
socket.add({
'jsonrpc': '2.0',
'method': '_registerService',
'method': 'registerService',
'params': {'service': serviceName, 'alias': serviceAlias}
});
@ -61,7 +61,7 @@ var tests = <IsolateTest>[
// Registering second service
socket.add({
'jsonrpc': '2.0',
'method': '_registerService',
'method': 'registerService',
'params': {'service': serviceName + '2', 'alias': serviceAlias + '2'}
});
@ -79,7 +79,7 @@ var tests = <IsolateTest>[
socket.add({
'jsonrpc': '2.0',
'id': 1,
'method': '_registerService',
'method': 'registerService',
'params': {'service': serviceName, 'alias': serviceAlias}
});

View file

@ -14,7 +14,7 @@ var tests = <IsolateTest>[
VM vm = isolate.owner;
final serviceEvents =
(await vm.getEventStream('_Service')).asBroadcastStream();
(await vm.getEventStream('Service')).asBroadcastStream();
WebSocket _socket =
await WebSocket.connect((vm as WebSocketVM).target.networkAddress);
@ -45,7 +45,7 @@ var tests = <IsolateTest>[
socket.add({
'jsonrpc': '2.0',
'id': 1,
'method': '_registerService',
'method': 'registerService',
'params': {'service': successServiceName, 'alias': serviceAlias}
});
@ -58,7 +58,7 @@ var tests = <IsolateTest>[
socket.add({
'jsonrpc': '2.0',
'id': 1,
'method': '_registerService',
'method': 'registerService',
'params': {'service': errorServiceName, 'alias': serviceAlias}
});

View file

@ -12,7 +12,7 @@ var tests = <VMTest>[
var result = await vm.invokeRpcNoUpgrade('getVersion', {});
expect(result['type'], equals('Version'));
expect(result['major'], equals(3));
expect(result['minor'], equals(21));
expect(result['minor'], equals(22));
expect(result['_privateMajor'], equals(0));
expect(result['_privateMinor'], equals(0));
},

View file

@ -15,7 +15,7 @@
namespace dart {
#define SERVICE_PROTOCOL_MAJOR_VERSION 3
#define SERVICE_PROTOCOL_MINOR_VERSION 21
#define SERVICE_PROTOCOL_MINOR_VERSION 22
class Array;
class EmbedderServiceHandler;

View file

@ -1,8 +1,8 @@
# Dart VM Service Protocol 3.21
# Dart VM Service Protocol 3.22
> Please post feedback to the [observatory-discuss group][discuss-list]
This document describes of _version 3.21_ of the Dart VM Service Protocol. This
This document describes of _version 3.22_ of the Dart VM Service Protocol. This
protocol is used to communicate with a running Dart Virtual Machine.
To use the Service Protocol, start the VM with the *--observe* flag.
@ -47,6 +47,7 @@ The Service Protocol uses [JSON-RPC 2.0][].
- [invoke](#invoke)
- [pause](#pause)
- [kill](#kill)
- [registerService](#registerService)
- [reloadSources](#reloadsources)
- [removeBreakpoint](#removebreakpoint)
- [resume](#resume)
@ -878,6 +879,21 @@ The isolate is killed regardless of whether it is paused or running.
See [Success](#success).
### registerService
```
Success registerService(string service, string alias)
```
Registers a service that can be invoked by other VM service clients, where
`service` is the name of the service to advertise and `alias` is an alternative
name for the registered service.
Requests made to the new service will be forwarded to the client which originally
registered the service.
See [Success](#success).
### reloadSources
```
@ -1071,6 +1087,7 @@ GC | GC
Extension | Extension
Timeline | TimelineEvents
Logging | Logging
Service | ServiceRegistered, ServiceUnregistered
Additionally, some embedders provide the _Stdout_ and _Stderr_
streams. These streams allow the client to subscribe to writes to
@ -1598,6 +1615,26 @@ class Event extends Response {
//
// This is provided for the Logging event.
LogRecord logRecord [optional];
// The service identifier.
//
// This is provided for the event kinds:
// ServiceRegistered
// ServiceUnregistered
String service [optional];
// The RPC method that should be used to invoke the service.
//
// This is provided for the event kinds:
// ServiceRegistered
// ServiceUnregistered
String method [optional];
// The alias of the registered service.
//
// This is provided for the event kinds:
// ServiceRegistered
String alias [optional];
}
```
@ -1683,6 +1720,14 @@ enum EventKind {
// Event from dart:developer.log.
Logging
// Notification that a Service has been registered into the Service Protocol
// from another client.
ServiceRegistered,
// Notification that a Service has been removed from the Service Protocol
// from another client.
ServiceUnregistered
}
```
@ -3081,5 +3126,6 @@ version | comments
3.19 | Add 'clearVMTimeline', 'getVMTimeline', 'getVMTimelineFlags', 'setVMTimelineFlags', 'Timeline', and 'TimelineFlags'.
3.20 | Add 'getInstances' RPC and 'InstanceSet' object.
3.21 | Add 'getVMTimelineMicros' RPC and 'Timestamp' object.
3.22 | Add `registerService` RPC, `Service` stream, and `ServiceRegistered` and `ServiceUnregistered` event kinds.
[discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observatory-discuss

View file

@ -1,8 +1,8 @@
# Dart VM Service Protocol 3.22-dev
# Dart VM Service Protocol 3.23-dev
> Please post feedback to the [observatory-discuss group][discuss-list]
This document describes of _version 3.22-dev_ of the Dart VM Service Protocol. This
This document describes of _version 3.23-dev_ of the Dart VM Service Protocol. This
protocol is used to communicate with a running Dart Virtual Machine.
To use the Service Protocol, start the VM with the *--observe* flag.
@ -47,6 +47,7 @@ The Service Protocol uses [JSON-RPC 2.0][].
- [invoke](#invoke)
- [pause](#pause)
- [kill](#kill)
- [registerService](#registerService)
- [reloadSources](#reloadsources)
- [removeBreakpoint](#removebreakpoint)
- [resume](#resume)
@ -878,6 +879,21 @@ The isolate is killed regardless of whether it is paused or running.
See [Success](#success).
### registerService
```
Success registerService(string service, string alias)
```
Registers a service that can be invoked by other VM service clients, where
`service` is the name of the service to advertise and `alias` is an alternative
name for the registered service.
Requests made to the new service will be forwarded to the client which originally
registered the service.
See [Success](#success).
### reloadSources
```
@ -1071,6 +1087,7 @@ GC | GC
Extension | Extension
Timeline | TimelineEvents
Logging | Logging
Service | ServiceRegistered, ServiceUnregistered
Additionally, some embedders provide the _Stdout_ and _Stderr_
streams. These streams allow the client to subscribe to writes to
@ -1598,6 +1615,26 @@ class Event extends Response {
//
// This is provided for the Logging event.
LogRecord logRecord [optional];
// The service identifier.
//
// This is provided for the event kinds:
// ServiceRegistered
// ServiceUnregistered
String service [optional];
// The RPC method that should be used to invoke the service.
//
// This is provided for the event kinds:
// ServiceRegistered
// ServiceUnregistered
String method [optional];
// The alias of the registered service.
//
// This is provided for the event kinds:
// ServiceRegistered
String alias [optional];
}
```
@ -1683,6 +1720,14 @@ enum EventKind {
// Event from dart:developer.log.
Logging
// Notification that a Service has been registered into the Service Protocol
// from another client.
ServiceRegistered,
// Notification that a Service has been removed from the Service Protocol
// from another client.
ServiceUnregistered
}
```
@ -3081,5 +3126,6 @@ version | comments
3.19 | Add 'clearVMTimeline', 'getVMTimeline', 'getVMTimelineFlags', 'setVMTimelineFlags', 'Timeline', and 'TimelineFlags'.
3.20 | Add 'getInstances' RPC and 'InstanceSet' object.
3.21 | Add 'getVMTimelineMicros' RPC and 'Timestamp' object.
3.22 | Add `registerService` RPC, `Service` stream, and `ServiceRegistered` and `ServiceUnregistered` event kinds.
[discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observatory-discuss

View file

@ -228,12 +228,12 @@ class VMService extends MessageRouter {
}
for (var service in client.services.keys) {
_eventMessageHandler(
'_Service',
'Service',
new Response.json({
'jsonrpc': '2.0',
'method': 'streamNotify',
'params': {
'streamId': '_Service',
'streamId': 'Service',
'event': {
"type": "Event",
"kind": "ServiceUnregistered",
@ -420,7 +420,7 @@ class VMService extends MessageRouter {
return null;
}
static const kServiceStream = '_Service';
static const kServiceStream = 'Service';
static const serviceStreams = const [kServiceStream];
Future<String> _streamListen(Message message) async {
@ -611,7 +611,7 @@ class VMService extends MessageRouter {
if (message.method == 'streamCancel') {
return await _streamCancel(message);
}
if (message.method == '_registerService') {
if (message.method == 'registerService') {
return await _registerService(message);
}
if (message.method == '_spawnUri') {