rethinkdb / horizon
- четверг, 19 мая 2016 г. в 03:12:41
JavaScript
Horizon is a realtime, open-source backend for JavaScript apps.
Horizon is an open-source developer platform for building sophisticated realtime apps. It provides a complete backend that makes it dramatically simpler to build, deploy, manage, and scale engaging JavaScript web and mobile apps. Horizon is extensible, integrates with the Node.js stack, and allows building modern, arbitrarily complex applications.
Horizon is built on top of RethinkDB and consists of four components:
hz
-- a command line tool aiding in scaffolding, development, and deploymentThe first version of Horizon will expose the following services to developers:
Upcoming versions of Horizon will likely expose the following additional services:
While technologies like RethinkDB and WebSocket make it possible to build engaging realtime apps, empirically there is still too much friction for most developers. Building realtime apps now requires understanding and manually orchestrating multiple systems across the software stack, understanding distributed stream processing, and learning how to deploy and scale realtime systems. The learning curve is quite steep, and most of the initial work involves boilerplate code that is far removed from the primary task of building a realtime app.
Horizon sets out to solve this problem. Developers can start building apps using their favorite front-end framework using Horizon's APIs without having to write any backend code.
Since Horizon stores data in RethinkDB, once the app gets sufficiently complex to need custom business logic on the backend, developers can incrementally add backend code at any time in the development cycle of their app.
We'd love for you to help us build Horizon. If you'd like to be a contributor, check out our Contributing guide.
Also, to stay up-to-date on all Horizon related news and the community you should definitely join us on Slack, follow us on Twitter, and join our Horizon mailing list at Horizon.io.
This first step is to install the Horizon command line tool.
$ npm install -g horizon
You can then create the boilerplate with hz init
and then launch Horizon Server
and an instance of RethinkDB with hz serve --dev
. RethinkDB needs to be installed and accessible from the Path.
$ hz init myapp
$ hz serve myapp --dev
# localhost:8181 has a demo page on it
# Horizon client connections can be made to ws://localhost:8181/horizon
# The horizon client library is served from localhost:8181/horizon/horizon.js
Check out the Getting Started guide for a complete walkthrough.
Here is currently what you'd write on the front-end for a simple todo list application:
// Connect to horizon
const horizon = Horizon();
const todoCollection = horizon("todo_items");
const todoApp = document.querySelector('#app')
// Function called when a user adds a todo item in the UI
todoCollection.watch().subscribe( todos => {
const todoHTML = todos.map(todo =>
`<div class="todo" id="${todo.id}">
<input type="checkbox" ${todo.done ? 'checked' : ''}>
${todo.text} -- ${todo.date}
</div>`);
todoApp.innerHTML = todoHTML.join('');
});
Want to see more? Check out our README for the Horizon client library, we have an initial set of docs as well as a expanded getting started guide to get you started with using Horizon.
You have two options:
npm install -g horizon
(we try to publish weekly)/test
folder here and run ./setupDev.sh
which will install it on your system using this repo.Refer to the the CLI README for the most up-to-date public install instructions.
Check out our Getting Started guide. If you have more questions, come join us on Slack in #horizon or feel free to tweet us at @horizonjs.
There are a few major differences:
Horizon has philosophical and technical differences with Meteor that will result in vastly different developer experiences.
Horizon is a small layer on top of RethinkDB with a narrow, purpose-built API designed to make it very easy to get started building realtime apps without backend code. Horizon isn't prescriptive -- you can use any front-end framework without any magic/customizations, and once your app outgrows the Horizon API you can use any backend technology (e.g. Node.js, Python, Ruby) and any backend framework (e.g. Rails, Express, Koa, etc.)
By contrast, Meteor is a much more prescriptive framework. Horizon is a reasonably small component that has a very clean separation with the database and the front-end, while Meteor is a much more monolithic experience.
Another major difference is architectural -- Meteor uses a LiveQuery component built by tailing MongoDB's oplog. This approach is fundamentally limited -- it's impossible to do many operations efficiently, and even the basic functionality is extremely difficult to scale.
Horizon is built on RethinkDB, so the LiveQuery functionality is in the database. This allows for much more sophisticated streaming operations, and scalability is dramatically simpler because the database has all the necessary information to allow for a scalable feeds implementation.
We still have to figure out the exact license, but Horizon will be fully open-source (we'll probably use MIT or Apache).