Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added default communication API docs and made client API

refactoring.
  • Loading branch information...
commit 65211e3d05b8ee462c0d864bd2a27863a7dedd05 1 parent c22dd2f
@BasicWolf authored
View
7 AUTHORS
@@ -1,7 +1,10 @@
+Authors
+=======
+
Kaylee is written and maintained by Zaur Nasibov.
Kaylee code has adopted some ideas from 3d-party products (see NOTICE).
-Development Lead
-================
+People
+------
* Zaur Nasibov <zaur@znasibov.info>
View
6 demo/src/kldemo.coffee
@@ -11,7 +11,7 @@ $(document).ready( () ->
kl.project_imported.bind(on_project_imported)
kl.task_received.bind(on_task_received)
kl.task_completed.bind(on_task_completed)
- kl.results_sent.bind(on_results_sent)
+ kl.result_sent.bind(on_result_sent)
kl.worker_raised_error.bind(on_worker_error)
kl.log.bind(on_log)
kl.server_raised_error.bind(on_server_error)
@@ -49,8 +49,8 @@ on_task_completed = (data) ->
completed.")
_tasks_counter += 1
-on_results_sent = () ->
- kl.console.print("The results have been sent to the server.")
+on_result_sent = () ->
+ kl.console.print("The result has been sent to the server.")
on_worker_error = (e) ->
kl.console.print("<span class='cerr'>WORKER ERROR:</span> Line #{e.lineno} in
View
3  doc/authors.rst
@@ -0,0 +1,3 @@
+.. _authors:
+
+.. include:: ../AUTHORS
View
12 doc/clientapi.rst
@@ -79,7 +79,7 @@ Core
* :js:attr:`register <kl.api.register>`
* :js:attr:`subscribe <kl.api.subscribe>`
* :js:attr:`get_action <kl.api.get_action>`
- * :js:attr:`send_results <kl.api.send_results>`
+ * :js:attr:`send_result <kl.api.send_result>`
Each of these calls corresponds to a particular method of the
:py:class:`Kaylee` object on the server side. The default (TODO)
@@ -112,10 +112,10 @@ Core
Gets next available action (see :py:meth:`Kaylee.get_action`).
Triggers :js:func:`kl.action_received`.
- .. js:attribute:: kl.api.send_results(data)
+ .. js:attribute:: kl.api.send_result(data)
Sends task results to the server (see :py:meth:`Kaylee.accept_result`).
- Triggers :js:func:`kl.results_sent` **and** in case that Kaylee
+ Triggers :js:func:`kl.result_sent` **and** in case that Kaylee
immediately returns a new action :js:func:`kl.action_received`.
.. js:attribute:: kl.app
@@ -163,9 +163,9 @@ Core
requirements (e.g. availability of web workers) tests.
-.. js:function:: kl.send_results(data)
+.. js:function:: kl.send_result(data)
- Invokes :js:attr:`kl.api.send_results`.
+ Invokes :js:attr:`kl.api.send_result`.
.. js:function:: kl.subscribe(app_name)
@@ -247,7 +247,7 @@ Events
Triggered when Kaylee worker finishes importing a project required
by an application (this includes successful call to :js:func:`pj.init`).
-.. js:function:: kl.results_sent(results)
+.. js:function:: kl.result_sent(results)
Triggered when Kaylee acknowledge the receipt of the task results.
View
7 doc/contents.rst.inc
@@ -13,6 +13,7 @@ instructions for deployment of Kaylee.
firststeps
tutorial/index
loading
+ default-communication
auto_filters
contrib
@@ -36,9 +37,11 @@ method, this part of the documentation is for you.
Additional Notes
----------------
-Design notes, legal information and changelog are here for the interested.
+..
+ Design notes, legal information and changelog are here for the interested.
.. toctree::
- :maxdepth: 2
+ :maxdepth: 1
license
+ authors
View
46 doc/contrib.rst
@@ -5,10 +5,54 @@ Contrib
.. module:: kaylee
-Kaylee comes with a small ``contrib`` library which currently plays a role
+Kaylee comes with a small ``contrib`` package which currently plays a role
of :py:class:`Controller`, :py:class:`TemporalStorage` and
:py:class:`PermanentStorage` implementation examples.
+Contrib also contains Flask and Django applications which support Kaylee :ref:`default-communication`.
+
+.. _contrib_front_ends:
+
+Front-ends
+----------
+
+The full example of using ``kaylee.contrib.frontends`` is available in
+:ref:`demo` application.
+
+Flask
+.....
+
+Kaylee provides Flask ``blueprint`` which can be used in the following
+fashion::
+
+ from flask import Flask
+ from kaylee.contrib.frontends.flask_frontend import kaylee_blueprint
+
+ app = Flask(__name__)
+
+ app.register_blueprint(kaylee_blueprint,
+ url_prefix = '/kaylee')
+
+
+Django
+......
+
+Kaylee provides Django ``application`` which can be used in the following
+fashion:
+
+.. code-block:: python
+
+ # Project's urls.py
+
+ from django.conf.urls import patterns, include, url
+
+ urlpatterns = patterns('',
+ ...,
+ url(r'^kaylee/', include('kaylee.contrib.frontends.django_frontend.urls'))
+ )
+
+
+
Controllers
-----------
View
65 doc/default-communication.rst
@@ -0,0 +1,65 @@
+.. _default-communication:
+
+Default Communication API
+=========================
+
+Although Kaylee comes with a default communication API, a user is free to
+communicate with Kaylee any way possible as long as the transferred data is
+kept in JSON format. The default API is implemented on both server
+(:ref:`contrib front-ends <contrib_front_ends>`) and client side
+(:js:attr:`kl.api`) is provided below.
+
+.. module:: kaylee
+
+Register
+--------
+
+=========== ==========================
+Server :py:meth:`Kaylee.register`
+Client :js:attr:`kl.api.register`
+URL ``/kaylee/register``
+HTTP Method ``GET``
+=========== ==========================
+
+
+Subscribe
+---------
+
+=========== ===============================================
+Server :py:meth:`Kaylee.subscribe`
+Client :js:attr:`kl.api.subscribe`
+URL ``/kaylee/apps/{app_name}/subscribe/{node_id}``
+HTTP Method ``POST``
+POST data null
+Parameters * ``app_name`` - Application name to which the
+ node is being subscribed.
+ * ``node_id`` - Node ID.
+=========== ===============================================
+
+
+Get Action
+----------
+
+=========== =============================
+Server :py:meth:`Kaylee.get_action`
+Client :js:attr:`kl.api.get_action`
+URL ``/kaylee/actions/{node_id}``
+HTTP Method ``GET``
+Parameters * ``node_id`` - Node ID.
+=========== =============================
+
+
+Accept Results
+--------------
+
+=========== ===============================
+Server :py:meth:`Kaylee.accept_result`
+Client :js:attr:`kl.api.send_result`
+URL ``/kaylee/actions/{node_id}``
+HTTP Method ``POST``
+Post Data Calculation results.
+=========== ===============================
+
+
+
+
View
11 doc/license.rst
@@ -4,15 +4,4 @@ License
Kaylee is licensed under the MIT license. When we speak of freedom, we mean
"free as liberty", but you can as well use it in "free as free beer" manner.
-.. _authors:
-
-Authors
--------
-
-.. include:: ../AUTHORS
-
-
-Kaylee License
---------------
-
.. include:: ../LICENSE
View
12 kaylee/client/kaylee.coffee
@@ -39,10 +39,10 @@ kl.api =
kl.server_raised_error.trigger)
return null
- send_results : (results) ->
+ send_result : (results) ->
kl.post("/kaylee/actions/#{kl.node_id}", results,
((action_data) ->
- kl.results_sent.trigger(results)
+ kl.result_sent.trigger(results)
kl.action_received.trigger(action_data)
),
kl._default_server_error_handler
@@ -72,9 +72,9 @@ kl.get_action = () ->
kl.api.get_action()
return null
-kl.send_results = (data) ->
+kl.send_result = (data) ->
if kl.app.subscribed
- kl.api.send_results(data)
+ kl.api.send_result(data)
return null
kl._message_to_worker = (msg, data = {}) ->
@@ -132,7 +132,7 @@ on_task_received = (data) ->
return null
on_task_completed = (data) ->
- kl.send_results(data)
+ kl.send_result(data)
return null
# worker event handlers
@@ -159,7 +159,7 @@ kl.task_received = new Event(on_task_received)
kl.task_completed = new Event(on_task_completed)
kl.log = new Event()
kl.worker_raised_error = new Event()
-kl.results_sent = new Event()
+kl.result_sent = new Event()
kl.server_raised_error = new Event()
window.kl = kl;
Please sign in to comment.
Something went wrong with that request. Please try again.