Comments (6)
A couple thoughts:
- It seems like we need a "DtdService" or "Service" stream available on DTD by default. Any client should be able to listen to this stream to receive events like
ServiceRegistered
andServiceUnregistered
. An example of an event like this might look like:{ 'type': 'ServiceRegistered' 'args': { 'service': 'editor', 'method': 'foo.bar', }
- I think we also need an API that a DTD client can call to
getRegisteredServices
or similar. This API can take an optional parameter to specify a single DTD client, like 'editor' or 'analysis_server', etc.
If we had both of these, we could avoid having to implement stream history like DDS does because each client could follow the workflow of:
- Call
getRegisteredServices
upon connection to DTD - Initialize the listener to the 'DtdService' or 'Service' stream thereafter to pick up changes to registered services.
from sdk.
I think we also need an API that a DTD client can call to
getRegisteredServices
or similar.
Do we need this too? I think when a client calls streamListen
for a stream, we could also just have the DTD server enumerate all registered services and send the events for those immediately?
I feel like it might simplify the client work slightly (you already need to handle the events arriving just after you started listening, so this avoids an extra API), but I haven't tried to implement it yet.
The other thing noted above is capabilities. I'm wondering whether we could make registerService
take an optional caapbilities
map that is included in these events, which would allow us to indicate which flags/behaviours might be available for a service:
await clientA.registerService(
'editor',
'openDevToolsPage',
(params) async {
// implementation
},
capabilities: {
'supportsPreferDebugSession': true,
},
);
Results in:
{
'type': 'ServiceRegistered' // (though this be ServiceRegistered when really it's a method?)
'args': {
'service': 'editor',
'method': 'openDevToolsPage',
'capabilities': {
'supportsPreferDebugSession': true.
}
}
WDYT?
from sdk.
I think we also need an API that a DTD client can call to
getRegisteredServices
or similar.Do we need this too? I think when a client calls
streamListen
for a stream, we could also just have the DTD server enumerate all registered services and send the events for those immediately?
I think this is probably the most robust way to do this. If clients have to subscribe to a stream and also manually request the current set of registered service it's really easy to get the ordering wrong, introducing a race condition that could result in the client possibly missing a newly registered service. If we always send the full set of registered services and methods upon stream subscription, there's only a single request needed by the client and we only need to worry about synchronization within DTD
The other thing noted above is capabilities. I'm wondering whether we could make
registerService
take an optionalcaapbilities
map that is included in these events, which would allow us to indicate which flags/behaviours might be available for a service:await clientA.registerService( 'editor', 'openDevToolsPage', (params) async { // implementation }, capabilities: { 'supportsPreferDebugSession': true, }, );Results in:
{ 'type': 'ServiceRegistered' // (though this be ServiceRegistered when really it's a method?) 'args': { 'service': 'editor', 'method': 'openDevToolsPage', 'capabilities': { 'supportsPreferDebugSession': true. } }WDYT?
I think this sounds reasonable and is low-risk. However, is there any situation where the capabilities might be different for a given service method? If not, can the capabilities not be
inferred?
from sdk.
I think this sounds reasonable and is low-risk. However, is there any situation where the capabilities might be different for a given service method? If not, can the capabilities not be inferred?
This is to support the methods capabilities changing over time. For example the editor provides an openDevToolsPage()
method. We recently added some new functionality that allows passing additional flags (requiresDebugSession
and prefersDebugSession
) to dictate whether the editor will try to provide a VM Service URI to the DevTools page being opened. Capabilities are to allow the client (eg. DevTools sidebar) to know before calling the method whether or not those flags are supported (because we don't know if we're running inside a new or old version of the VS Code plugin).
Another option would be to register methods with new names for each change, but I think that explode quickly.
from sdk.
That makes sense. Allowing for services to provide capabilities SGTM.
from sdk.
Thanks - I made a start on this and have pushed what I have so far https://dart-review.googlesource.com/c/sdk/+/372940 in case anyone has chance to review and check it's going in the right direction before I resume tomorrow :)
from sdk.
Related Issues (20)
- Add @Since annotations to JS APIs added in 3.6 HOT 1
- Incorrect dead code removal quick fix when multiple cases share a body HOT 1
- [CP] Revert "analyzer: separate unused_element_parameter from unused_element" HOT 1
- [Augmentations] No error in analyzer when augmenting constructor has wrong number of parameters
- [Augmentations] No error in analyzer when augmenting constructor parameters have different optionality
- [Augmentations] No error in the analyzer to specify parameters for `augmented()` in an augmenting generative constructor
- [Augmentations] No error in analyzer if `augmented` is torn-off in the augmenting constructor body
- `VMService::dispose` will complete outstanding requests with `RPCError`s that lack stack traces HOT 3
- [Augmentations] No error in the analyzer if introductory and augmenting constructors have super initializers
- [Augmentations] Initializer list in augmenting constructor produces errors in the analyzer
- Optimize `TypedData.setRange()` for case where `from`/`to` are from different worlds (one is JS typed data one is internal typed data)
- [Augmentations] No error in the analyzer when late variable is augmented with non-late
- [Augmentations] No error if a late final variable with no initializer is augmented by the one with initializer
- [Augmentations] No error in the analyzer if const is augmented by a getter
- [web] [DDC] TypeError: Cannot read properties of undefined (reading 'new') HOT 13
- Running `dart devtools` with `dart` on `PATH` fails on 3.5.1 HOT 1
- [CP] [ CLI ] Fix issue where 'dart build' would fail to find the 'dart' when run from PATH HOT 2
- community contribution to the cli_utils library (depended upon by the sdk) HOT 1
- [dart2wasm] make `dart.library.js_util` false on conditional imports HOT 1
- Issue with Dart Content Script in Firefox Extension: browser and chrome Undefined HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk.