-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dedicated methods for DNS-SD, CoRE Link-Format discovery, and other approaches? #535
Comments
If we want to introduce more specialized methods I would rather use a configuration option that can be passed in in some way so that if we want to add yet another way of discovering the option needs to be updated and not yet a new method needs to be created. |
Yeah, that sounds reasonable, I think. Maybe this approach could actually also be used for DNS-SD and CoRE Link-Format after all. However, I've got the feeling that we should consider changing the return type to URLs instead of Thing Descriptions, so that we use the What could the shape of the configuration option look like? Would it make sense to have something like {
"method": "dns-sd",
"domainName": "_wot._tcp.example.org.",
} where the |
There have been two design approaches:
I think it makes sense to separate the methods for introduction phase (that return links or directories), which are a new thing since the discovery TF started working. Then, discovery will (continue to) return TDs. The API design should consider following:
We could contain discovery related functionality in its own namespace, or object. It could contain the following:
I like stateless interactions more, so I'd prefer the approach via options (with default values), and hiding processing the directories/links by the runtime, providing only the TDs to the app. But if we want a control point in the apps, then we need an additional method, that handles the introductory phase, and the returned stuff can be used as options to the second phase, as above. In the end, we just need an additional introductory phase method, named e.g. |
Call 13/05: |
I've been experimenting a bit with different approaches for the My current approach now looks something like the example below. Here, the final servient = Servient.create(
clientFactories: [
HttpClientFactory(),
],
discoveryConfigurations: [
// Use DNS-SD with mDNS for discovery
DnsSdDConfiguration(
protocolType: ProtocolType.tcp,
discoveryType: DiscoveryType.thing,
),
],
);
final wot = await servient.start();
await for (final thingDescription in wot.discover()) {
// Handle discovered Thing Description
} I think that is actually a quite simple solution that also enables you to quickly perform a rediscovery of TDs and that can also be extended with new methods in the future. As mentioned in #551, this also corresponds pretty much with what is already specified in the Scripting API. The only downside might be that, if you want to perform different discovery procedures, you first need to reconfigure the Servient and then re-invoke the So the question I had here was if we want to make it possible to override the default configuration defined in the underlying platform via a set of “well-known” configurations or if we should at least create some sort of extension point (i.e., an object for options that is passed to the |
Wouldn't be better having a separate object that deal with the discovery lifecycle and pass it to a function that returns an iterable of TDs ? e.g a |
@JKRhb Using a discovery API that is passed discovery options, an app could specify multiple discovery options, the implementations could span a discovery process (session) for each type of options separately, and collect the results for the app. In addition, when an app would start another additional discovery process with different (or overlapping) discovery options, the implementation could break it down to suitable discovery transactions/processes and manage those behind the scenes, just providing the results to the app. So I would decouple the API / SW interface of doing discovery from the app, from the actual implementations that needs to comply with the Discovery spec, and map the app requests to suitable discovery transactions/processes. This design decision would work when there is 1:1 mapping between discovery API and discovery process, and also when there is something to encapsulate (the discovery processes in the background may change more often, but the API should not change that often). |
Hmm, I think I somehow misunderstood you, @zolkis, and for some reason thought that const discoveryOptions = [
{
"type": "dns-sd",
...
},
{
"type": "core",
...
},
];
// Variant 1 (in accordance with the current API design)
const discoveryProcess = await wot.discover({ discoveryOptions });
for await (const thingDescription of discoveryProcess) {
// Handle thingDescription
}
// Variant 2 (without awaiting a discoveryProcess)
for await (const thingDescription of wot.discover({ discoveryOptions })) {
// Handle thingDescription
} This approach might be a bit simpler than instantiating separate objects for the discovery lifecycle, as things would be handled behind the scenes according to the configurations that have been passed in. However, this way you would probably need to specify the available options or provide a way for the user to find out which configurations are supported by the platform. |
Most of the discovery processes can be one-off or long-running, so having an object that can be at least started, stopped and queried separately might be good. |
Hmm, yeah, that is a good point. The alternative would be to provide a timeout parameter in the configuration so that a discovery process would be cancelled automatically after some time. I suppose we could also consider having both kinds of APIs, so a set of “built-in” discovery methods (that do not require the instantiation of a separate object for discovery), and an interface that would also allow for the addition of custom/adjusted discovery mechanisms. Using only one approach would also work for me, though. |
Right, so I think we are back to something like the old discovery API:
The main question was how to map 2-phase discovery to the API. |
Experimenting with both DNS-SD and discovery via the CoRE Link-Format in dart_wot, I got the impression that it could make sense to add dedicated discovery methods for both approaches and maybe even replace the generic
discover
method in this context.As the two approaches belong to the introduction phase, the new methods could be used solely for discovering URLs pointing to Things, which could be wrapped in objects containing a
url
and atype
(such asThing
orDirectory
). The results could then be followed up with either therequestThingDescription
or theexploreDirectory
method. As multiple incoming responses are possible when using multicast with both approaches, the two new methods could once again return anAsyncIterable
which would enable an asynchronous processing of the results.I think both approaches (and especially the case of using DNS-SD with multicast DNS) can be motivated via use cases quite well. However, I wanted to create an issue in this regard already since it also concerns a general design question if adding new methods to the
WoT
namespace would be the way to go here or if we risk making the API surface a bit too large. Is there maybe also a concept of sub-namespaces in WebIDL?Another question we could also discuss in this regard concerns the generic
discover
method. Should we keep it as it is right now or should we maybe also replace it with more specialized methods in the future (likediscoverNearbyThings
ordiscoverThingsViaBluetooth
)? From what I've seen so far when it comes to discovery with Bluetooth and NFC, I suppose that the return type of such methods could also be a URI or anAsyncIterable
of URIs, right?At some point, we might want to ask the same questions regarding DID – generally speaking, I think there is the question of which methods defined in the Discovery spec we should support directly and which should be delegated to "userland".
The text was updated successfully, but these errors were encountered: