-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: parameterise resources #6
Comments
Wat? |
Yes Wat! (Note: will post something more relevant in the morning :), just about to knock out).. Sent from my iPhone
|
@mstade: To elaborate on that, the core assumption is that components all work as |
What's a stream? What does it look like? |
That's my point, actually. Streams in all their incarnations in js land are just event emitters, and given components are effectively event handlers, why add more to the mix? You already have a stream, is what I'm saying. |
👍 :) |
Ok, so some more thoughts: Thus far I've been freestyling a bit (albeit, consistently) with terminology around resources. It's important to tidy this up as it will impact the structure/extension of the project. Looking around, there is a few terms I'd like to introduce: URI, URN, URC, URL. I'm aware some of these have fallen out of fashion, but the distinctions are conceptually useful for discussion. We have today: // Definition
ripple.resource('{urn}', {resource}, {urc})
// Declarative Invocation
<{urn1} data='{urn2}' />
// Imperative Invocation
ripple('{urn}') // i. synchronous
ripple('{urn}').on('response', function(){ }) // ii. asynchronous where:
Now, in this light, there are two options (note: "classical vs contemporary" reference to W3C Note 21): ClassicalIf we were to stick to the classical approach (uri=(urn+urc)||url), we would use the URC to "bind a URI's associated URN to its URL(s)": // Definition
ripple.resource('{urn}', {resource}, { url: ['/route1/:param', '/route2/:param'] }) A handler (perhaps, per-URL handler) would be invoked everytime ContemporaryThe contemporary understanding acknowledges that a URI can be a URN, URL or both. Currently, we can already create a "hollow resource". In the following example, "users" will be populated from a database, but the "colleagues" resource body will always be empty on the server. Using the proxies, when the body is changed (from client) we do nothing ( ripple
.resource('users', [])
.resource('colleagues', [], { from: from, to: to })
function from(req){
return false
}
funtionc to(res){
return ripple('users')
.filter(by('team', res.currentUser.team))
} We can extend this slightly, to allow parameterised names (routes): ripple
.resource('tweets', [])
.resource('/tweets/latest/:quantity', function(req, res){ .. }) Where a route is defined (leading slash), it will internally be defined similar to a hollow resource. It will have access to parameters under So the final technical definition would be: ripple
.resource('{uri}', {body}, {urc}) // actual resource
.resource('{uri}', {handler}) // route, hollow resource Bonus: NamespacesWe only support one-to-many server-client relationships (many databases is conceptually not hard to do with similar proxies/hooks). This means that one server de facto defines one namespace, one web boundary of resources. If we allowed sever nodes to communicate, how would we demarcate namespaces? More importantly, how can this be achieved in a decentralised fashion? This is where the allure of URN's comes back over URL's.. // somewhere in Manchester..
ripple
.resource('urn:nhs:patients', ..)
// somewhere in London..
ripple
.resource('urn:nhs:patients', ..)
// then, some GP-hacker in Scotland should be able to enter in devtools:
ripple('urn:nhs:patients:1') // record for patient 1
ripple('urn:nhs:patients:2') // record for patient 2 But, I haven't thought much about decentralised resource definition/resolution yet.. Any thoughts/totally different perspectives how realtime resources should be defined/other challenges? @mstade @sammyt @mamapitufo @gabrielmontagne @tomsugden @mere @pgn-vole @dantrain @bitoiu @dantrain @aaronhaines @haggyj @jhollingworth |
I don't think the leading
Headers may be attached to a message, but is just as much "tied" to a resource as the URI or other data. Consider the As far as I know, URC never went anywhere, and URN and URL are basically bundled up in the term URI to make it less confusing to talk about both at the same time. Whether or not a URI can be resolved into an actual location (i.e. it is also a URL) is probably more tied to the scheme semantics than anything. For instance
I disagree, you're just overloading URNs at this point. Instead, consider the generic URI syntax which states that the authority component is preceded by |
Thanks for the feedback @mstade! So, what would be the final API you would propose? (definition, declarative and imperative usage example would be appreciated).
Sorry, by deprecated I should have said no longer used. More importantly, I was making the point that the leading
Agree. But my hesitation is that the problem with using "headers" to describe resource metadata at rest, is not the fields that are permanently fixed (link), but the ones that are not. In the process of sending a resource to two different clients, it is likely that some header fields/values will not be the same. This indicates that they are generally specific to the transfer (i.e. HTTP) rather than strictly the resource, or even it's many possible representations. Thoughts?
This one is tangential, but see the sentence:
i.e., within a particular context (ripple) you could know how to resolve that (
How exactly do you mean URNs being overloaded here?
Going back to the original question at the top of this post, could you give some examples of how you are thinking this would look practically? Would everything be prefixed with //, etc? |
Potato/tomato I guess. Any string or number fits that definition to be honest; identifiers are only as useful as their context, which I suppose is your point. But depending on environmental context (i.e. ripple) to attach semantics to an identifier is out-of-band galore and prone to break whenever that environment changes. (Because it will.) To that point, I think there's some confirmation bias going on here:
I don't think that's what RFC3986 is trying to say. Rather, it's saying that the scheme shouldn't have to declare all possible permutations, and that the naming authority (e.g. in the case of HTTP this would be the domain) can and will have the power to create and maintain new identifiers. The scheme should still define the semantics of the URI, otherwise anyone looking to use these identifiers would have to understand out-of-band information such as environment implementation. The beauty of something like http URIs is that I don't have to understand whether the naming authority is an Apache server, or Node.js, or nginx or whatever, because the common contract here is the scheme, even though the scheme doesn't dictate all identifiers. Now, if you designed your own scheme called
Well, the URN scheme explicitly says the identifier are location-independent.
Yes, I'd say. Anything not prefixed with |
@mstade agree with your comments and looking forward to see the work on rhumb. Still not exactly clear on how you would define/invoke a resource though - could you give a couple of examples? It may be easier to discuss and explain in person what I was thinking re:decentralised resource (:coffee:?).. |
Sounds like a splendid idea, I think we're overdue for a tete-a-tete anyhow. :o) |
More discussion around data-fetching layer in rijs/hypermedia#1. Leaning towards adding first-class support for subresources via dot notation in the next release. This is much easier to decompose, dedupe, manage subscriptions, etc than the GraphQL syntax. |
Consider using @sammyt's rhumb library for more RESTful style resource identification. Currently we are bombing all resources to all nodes. This was restricted per-resource with marking some resources as
private
. However, the mobile clients (@gangji91, @3liv) are struggling with loading entire collections. After parameterisation, we should also look to implement backpressure. So, instead of:It would look more like:
or
(I was planning on dropping the requirement to have the type in the name already).
This example makes me wonder though whether we can do more with implementation using streams - which would enable more FRP style components. Or would it complicate them..
The text was updated successfully, but these errors were encountered: