-
Notifications
You must be signed in to change notification settings - Fork 15
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
docs: richer documentation #14
Merged
hariharshankar
merged 1 commit into
mementoweb:master
from
tiborsimko:richer-docs-with-wiki
May 17, 2016
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
.. _advanced_features: | ||
|
||
TimeMaps | ||
======== | ||
|
||
The TimeGate can easily be used as a TimeMap server too. ## Requirements | ||
For that there are two requirements: | ||
|
||
- The Handler must implement the ``get_all_mementos(uri_r)`` function to return | ||
the entire history of an Original Resource. | ||
|
||
|
||
- The ``conf/config.ini`` file must have the variable ``use_timemap = true``. | ||
|
||
Resulting links | ||
--------------- | ||
|
||
Once this setup is in place, the TimeGate responses' ``Link`` header | ||
will contain two new relations, for two different formats (MIME types): | ||
|
||
- ``<HOST/timemap/link/URI-R>; rel="timemap"; type="application/link-format"`` | ||
`Link TimeMaps <http://www.mementoweb.org/guide/rfc/#Pattern6>`_ | ||
|
||
- ``<HOST/timemap/json/URI-R>; rel="timemap"; type="application/json"`` JSON | ||
TimeMaps | ||
|
||
Where ``HOST`` is the base URI of the program and ``URI-R`` is the URI | ||
of the Original Resource. | ||
|
||
Example | ||
------- | ||
|
||
For example, suppose ``http://www.example.com/resourceA`` is the URI-R | ||
of an Original Resource. And suppose the TimeGate/TimeMap server's | ||
``host`` configuration is set to ``http://timegate.example.com`` Then, | ||
HTTP responses from the TimeGate will include the following: | ||
|
||
- ``<http://timegate.example.com/timemap/link/http://www.example.com/resourceA>; rel="timemap"; type="application/link-format"`` | ||
- ``<http://timegate.example.com/timemap/json/http://www.example.com/resourceA>; rel="timemap"; type="application/json"`` | ||
|
||
Now a user can request an ``HTTP GET`` on one of those link and the | ||
server's response will have a ``200 OK`` status code and its body will | ||
be the TimeMap. | ||
|
||
HandlerErrors | ||
============= | ||
|
||
Custom error messages can be sent to the client using the custom | ||
exception module: ``from errors.timegateerrors import HandlerError``. | ||
For instance, a custom message with HTTP status ``400`` and body | ||
``Custom error message`` can be sent using: | ||
``raise HandlerError("Custom error message", status=400)``. Raising a | ||
``HandlerError`` will stop the request and not return any Memento to the | ||
client. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
.. _big_picture: | ||
|
||
Big picture | ||
=========== | ||
|
||
Definitions | ||
----------- | ||
|
||
From now on, this documentation will refer to the web server where | ||
resources and archives are as the **web server** and to the Memento | ||
TimeGate datetime negotiation server as the **TimeGate**. | ||
|
||
- Suppose you have a web resource accessible in a web server by some | ||
URI. We call the resource the **Original Resource** and refer to its | ||
URI as **URI-R**. | ||
- Suppose a web server has a snapshot of what this URI-R looked like in | ||
the past. We call such a snapshot a **Memento** and we refer to its | ||
URI as **URI-M**. There could be many snapshots of URI-R, taken at | ||
different moments in time, each with their distinct URI-Ms. The | ||
Mementos do not necessary need to be in the same web server as the | ||
Original Resources. | ||
|
||
Client, Server and TimeGate | ||
--------------------------- | ||
|
||
This figure represents the current situation; Without date time | ||
negotiation, the client has to find by hand the URIs for the previous | ||
versions of a web resource. If they exists: |client_server.png| To make | ||
this web resources Memento compliant, two things need to be added. The | ||
new components of the systems are the TimeGate and Memento HTTP headers | ||
at the web server's side: |client_server_tg.png| With these links, the | ||
client now gets the address of the TimeGate when retrieving an Original | ||
Resource or a Memento. Then, he can use datetime negotiation with the | ||
TimeGate to get the URI of an archived version (``URI-M2``) of the | ||
Original Resource at specific a point in time (``T2``): |sequence.png| | ||
|
||
Architecture | ||
------------ | ||
|
||
The TimeGate will manage the framework's logic in a generic manner. | ||
However, every web server has its specific way to store snapshots and to | ||
construct URI-Ms. Thus, a specific plugin must be written for every web | ||
server. Such a plugin is called a handler. A handler will typically talk | ||
to an API to return the list of URI-Ms given a URI-R, but there are | ||
several alternatives to this setup. | ||
|
||
.. figure:: architecture.png | ||
:alt: architecture.png | ||
|
||
architecture.png | ||
|
||
The system can be seen as three components. | ||
|
||
- The Memento user who wishes to retrieve an older version of a | ||
resource | ||
- The web server where the active version (original URI) and revisions | ||
(mementos) can be accessed. This entity must provide a way to access | ||
these versions. Typically through an API. | ||
- The TimeGate which itself is composed of two main elements: | ||
- One API-specific handler | ||
- The generic TimeGate code | ||
|
||
.. |client_server.png| image:: client_server.png | ||
.. |client_server_tg.png| image:: client_server_tg.png | ||
.. |sequence.png| image:: sequence.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
.. _cache: | ||
|
||
Cache | ||
===== | ||
|
||
The TimeGate comes with a built-in cache that is activated by default. Change | ||
this behavior editing in the configuration file. See :ref:`configuration`. | ||
|
||
Populating the cache | ||
-------------------- | ||
|
||
The cache stores TimeMaps which is the return values of the handler | ||
function ``get_all_mementos()`` only: - If the Handler does not have | ||
``get_all_mementos()`` implemented, the cache will never be filled. - If | ||
the Handler has both the functions ``get_all_mementos()`` and | ||
``get_memento()``, only TimeMap requests will fill the cache. All | ||
TimeGate requests will use ``get_memento()`` which result will not be | ||
cached. | ||
|
||
Cache HIT conditions | ||
-------------------- | ||
|
||
- Cached TimeMaps can be used used to respond to a TimeMap request from | ||
a client if it is fresh enough. The tolerance for freshness can be | ||
defined in the configuration file. | ||
- Cached TimeMap can also be used to respond to a TimeGate requests | ||
from a client. In this case, it is not the request's time that must | ||
lie within the tolerance bounds, but the requested datetime. | ||
|
||
Force Fresh value | ||
----------------- | ||
|
||
If the request contains the header ``Cache Control: no-cache``, then the | ||
TimeGate will not return anything from cache. | ||
|
||
Example | ||
------- | ||
|
||
Suppose you have a TimeMap that was cached at time ``T``. Suppose you | ||
have a tolerance of ``d`` seconds. A TimeMap request arrives at time | ||
``R1``. A TimeGate request arrives at time ``R2`` with requested | ||
datetime j. This request does **not** contain the header | ||
``Cache Control: no-cache``. - A TimeMap request will be served from | ||
cache only if it arrives within the tolerance: ``R1 <= T+d``. - A | ||
TimeGate request will be served from cache only if the requested | ||
datetime happens within the tolerance: ``j <= T+d``, no matter ``R2``. | ||
This means that even if a cached value is old, the cache can still | ||
respond to TimeGate requests for requested datetimes that are until time | ||
``T+d``. - All other requests will be cache misses. | ||
|
||
Cache size | ||
---------- | ||
|
||
There is no "maximum size" parameter. The reason for this is that the | ||
cache size will depend on the average size of TimeMaps, which itself | ||
depends on the length of each URI-Ms it contains, and their average | ||
count. These variables will depend on your system. The cache can be | ||
managed using the ``cache_max_values`` parameter which will affect | ||
indirectly its size. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command does not install
uwsgi
, as a result the following command does not work out of the box, unlessuwsgi
is installed separately.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the time being I have not amended any instructions, I have only copied existing
INSTALL.rst
. This we better amend separately. BTW, the properpip
example instruction would be:$ pip install -e git+https://github.com/mementoweb/timegate.git#egg=TimeGate[uwsgi]
This would install
uwsgi
too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tiborsimko you beat me by a fraction of a minute. ;-)