Giter Club home page Giter Club logo

Comments (6)

kenzieschmoll avatar kenzieschmoll commented on September 13, 2024

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 and ServiceUnregistered. 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:

  1. Call getRegisteredServices upon connection to DTD
  2. Initialize the listener to the 'DtdService' or 'Service' stream thereafter to pick up changes to registered services.

from sdk.

DanTup avatar DanTup commented on September 13, 2024

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.

bkonyi avatar bkonyi commented on September 13, 2024

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 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?

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.

DanTup avatar DanTup commented on September 13, 2024

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.

bkonyi avatar bkonyi commented on September 13, 2024

That makes sense. Allowing for services to provide capabilities SGTM.

from sdk.

DanTup avatar DanTup commented on September 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.