Skip to content

WoT.consume(USVString url) sufficient for consuming things? #69

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

Closed
danielpeintner opened this issue Oct 17, 2017 · 6 comments
Closed

WoT.consume(USVString url) sufficient for consuming things? #69

danielpeintner opened this issue Oct 17, 2017 · 6 comments

Comments

@danielpeintner
Copy link
Contributor

WoT used to have methods to consume ThingDescriptions based on a given URL but also based on a stringified JSON (object). The latter one has been removed.

Hence,

  • do we still see use-cases that should allow for consuming a stringified TD?
  • is it a solution to wite a local file instead that can be passed as URL?
  • use data uri (e.g., 'data:application/json;charset=utf-8, ...')

The only down-side I see with these solutions is that implementations need to have protocol support for http, file, data, ... while a plain string processing is supported out-of-the-box.

@zolkis
Copy link
Contributor

zolkis commented Oct 18, 2017

We could theoretically split the fetch() and consume() parts,

Promise<USVString> fetch(url);  // or fetchDescription
Promise<ConsumedThing> consume(USVString description);

Alternatively, we could have a combined argument type:

typedef (ThingInit or USVString) ThingSource;
Promise<ConsumedThing> consume(ThingSource source);

then we could say
wot.consume("https://mythings.com/mything1").then((thing) => { ... });

or

wot.consume({ url: "https://mythings.com/mything1"}).then((thing) => { ... });

or

wot.consume({ 
    contentType: "application.json",
    description: "{ \
          // here come the TD specified e.g. as JSON \
    }"
  }).then((thing) => { ... });`

where ThingInit is defined as in the spec (name, url, description properties), plus a contentType property for the TD serialization. The client code can also give a local (user defined) name for the consumed thing.

@danielpeintner
Copy link
Contributor Author

I like the idea of separating the processing steps to fetch() and consume().

The only "update" to your proposal for me would be changing the signature of consume to

Promise<ConsumedThing> consume(ThingDescription description);

We don't know yet what ThingDescription will become once. At the moment it is typed as USVString.

@mkovatsc
Copy link
Contributor

When splitting, why not revert to consume() and consumeUri() ?
What was the reason to consolidate? I guess the parameter object passing felt like offering this...

@zolkis
Copy link
Contributor

zolkis commented Oct 25, 2017

It was a lengthy discussion. The "pro" argument for splitting to fetch() and consume(): in web API design fetch is a well known procedure, it also has its standard. It outsources connection and security issues to another (possibly external) algorithm than the consume() algorithm.

The "con" arg would be that WoT fetch may be so different from the Fetch standard that the name would just create more confusion. This is a "social" hypothesis and needs to be checked before we base API decisions on it. But even if it's valid we could use fetchDescription() name which avoids confusion.

@danielpeintner
Copy link
Contributor Author

I still think having a 2 step approach to consume a TD makes sense.

Step1 (optional), fetching a TD might involve protocol bindings based on an URL such as retrieving a TD from an http, coap, data, ...URL. This process might become rather complex also with regard to security.

Step2, actually consuming a TD based on a ThingDescription "object/representation" is straight forward. Step2 is required and does not restrict "where" the TD comes from...

@zolkis zolkis mentioned this issue Oct 27, 2017
@zolkis
Copy link
Contributor

zolkis commented Feb 14, 2018

Addressed by #86.

@zolkis zolkis closed this as completed Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants