-
Notifications
You must be signed in to change notification settings - Fork 350
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
Custom Horizon commands #337
Comments
That's a really great idea! It might also be cool and even more powerful to pair it with the comment-parsing / annotation-parsing suggested and commented on here. A dev could simply stick a ReQL query where Horizon queries fall short, defining the custom command directly above the call-code (in a comment or annotation). For future-proofing / forwards-compatibility it might make more sense to provide a single API for custom commands, like: horizon.command('countLabels', {x: 12, y: 13}).fetch() |
I think theoretically we could have the server send custom supported commands and arities in the connection handshake. So it should be possible to integrate them a bit better dynamically |
I've been thinking about supporting something like this in the admin user interface, so you can graphically add new endpoints to Horizon—similar to what I've already done in Basejump. I think it'd be a great feature, and I think being able to manage it through the admin interface would be fantastic. |
This was previously discussed in #12. I think part of this should include exposing |
I also think it should be possible to write non-ReQL custom commands, which is where the programmatic API is more powerful. This should probably include the ability to implement a "watch" for such commands. For example, you might poll some third-party service or a |
Hi, I'm hoping I can give some feedback on this. I've been trying out add_request_handler on a server using horizon as a package. Right now im using it to both do the first query that i mostly setup as my "trigger" for to when new data should be sent to the client, mostly using The really awesome thing that after that i in some cases have four new queries after that changeFeed placed in a custom subscription handler, and when all this data is collected i then process it using moment.js for charts, i do joi validations for inserts, so on, so on. So i read the suggestions for a ui and stuff like that and its all good, but please keep this way of doing it open. I understand your best case scenario would be to cover as many suggestions as possible and thats great but i see the greatest potentials in this. Just this one thing i did last week, i did an endpoint for a simple insert, but to it i added joi validations to the complete object with custom error messages, than if something was wrong i just return an object like So now i can benefit from the speed of sockets delivering my error msgs i do server side validation and as soon as i have some auth running it will all be protected by jwt. Also a previous suggestion is to allow non query calls, that i want to add to. Just an option to returning false instead of an query in An example for this is that i have a system setup with lots and lots of filters built up as trees based on values of the documents and lets say its 5000 documents. And just think what these endpoints actually could be capable of, since connecting to them requires an handshake that is in some way is authorizing the user. If i could also do some customizations to the actual emits i could for example add possibilites to have pausable file uploads/downloads that is always If there is or will be a node lib for the client, all communication between my servers could be authenticated through the db and be using sockets just by those endpoints. So to sum it up. |
@stellanhaglund - I've actually reworked how endpoints are created in the permissions branch (see PR #331). Adding a request handler is the same, but the endpoint must expose a different interface. At the moment, that is a single function:
So now endpoints are in charge of managing the lifetime of their own ReQL queries and cursors, but this is far more flexible in allowing access to different APIs or types or requests. Let me know if this causes problems for you, or if you have any suggestions for this interface. |
@Tryneus okay so something like this?
do I need to add some kind of groups, permissions and rules? saw you have slack a profile, started a conversation there if you have time. |
This feature should be implemented as a plugin, see #588 |
It might be worth making this an integrated part of Horizon in my opinion since easy extensibility is a central feature of Horizon. |
Just for modularity's sake we should probably split it out, since not everyone will want this. It also seems like it wouldn't require more deep integration into the horizon guts than a plugin can provide, so there's not really much reason to couple it more tightly |
I think this makes sense in core. |
I agree that this should be in core and (potentially?) automatically reloaded on change with a flag or with I am new to Horizon and after the initial wow factor wore off, the real wow factor kicked in. That's when you start asking "Oh and can I…?" questions and I hit limitations. I am about to combine horizon and rethinkdb so that I can keep the easy wins of Horizon but add rethinkdb code and other services. I really like the potential of @marshall007's suggestion that non-ReQL commands could be used and the proposal in #345 might allow for arbitrarily complex commands per development needs but still allow good organization, etc. Really good stuff happening here! |
I don't yet know enough of horizon/rethinkdb internals but is there a way to start experimenting with these concepts the way @stellanhaglund mentioned?
[edit] @stellanhaglund @Tryneus Just confirming if this is what's needed:
meaning we do have a way to do this sort of thing now without modifying the core. |
Definitely, check out horizon.io/docs/embed On Sun, Jul 17, 2016, 04:32 Michael Wills notifications@github.com wrote:
|
It would be truly awesome if i could use the horizon socket system to make an call to my backend, and not only being able to do advanced reql queries, but doing anything. I could do validation with joi, throw errors, connect to other systems etc. |
Exposing a way to run custom ReQL queries through Horizon would be huge. My initial excitement over Horizon was tempered when I quickly ran into the limitations of the current Collections API. The standard response to this that I've seen is to embed Horizon into, say, an express app and implement custom endpoints for doing more complex ReQL. But then that leaves me with two different ways to access my data, which I don't like one bit. I've been looking into other solutions including this, but I would love to be able to just use Horizon. |
@deontologician I don't see any mention of add_request_handler there? im still confused as how you can do pagination with this. |
We should allow creating custom commands that map to parameterized reql queries.
There would be two parts:
The server and client would need to be changed
Example config:
On the frontend, you may use it like:
If you use fetch, it would run the query directly. If you use watch() it will append
.changes()
to the query and then run it. The query would simply fail if it doesn't support changes.This would add easy extensibility, where instead of going from easy Horizon straight to roll your own backend, you can go to RPC reql queries as a nicer intermediate step.
The text was updated successfully, but these errors were encountered: