Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Empty file added docs/_static/.gitkeep
Empty file.
189 changes: 189 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""This is an autogenerated sphinx config module."""
# pylint: disable=invalid-name
# pylint: disable=redefined-builtin
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
from os import environ
from os.path import abspath, join
from recommonmark.parser import CommonMarkParser

# -- Project information -----------------------------------------------------

project = 'Pacifica Dispatcher Example'
copyright = '2019, David Brown'
author = 'David Brown'

# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = ''


# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_parsers = {
'.md': CommonMarkParser,
}
source_suffix = ['.rst', '.md']

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'PacificaDispatcherExampledoc'


# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'PacificaDispatcherExample.tex', 'Pacifica Dispatcher Example Documentation',
'David Brown', 'manual'),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'pacificadispatcherexample', 'Pacifica Dispatcher Example Documentation',
[author], 1)
]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'PacificaDispatcherExample', 'Pacifica Dispatcher Example Documentation',
author, 'PacificaDispatcherExample', 'One line description of project.',
'Miscellaneous'),
]


# -- Options for Epub output -------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']


# -- Extension configuration -------------------------------------------------
autodoc_default_options = {
'member-order': 'bysource',
'special-members': '__init__',
'undoc-members': None,
'exclude-members': '__weakref__'
}
80 changes: 80 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Configuration

The Pacifica Core services require two configuration files. The REST
API utilizes [CherryPy](https://github.com/cherrypy) and review of
their
[configuration documentation](http://docs.cherrypy.org/en/latest/config.html)
is recommended. The service configuration file is a INI formatted
file containing configuration for database connections.

## CherryPy Configuration File

An example of UniqueID server CherryPy configuration:

```ini
[global]
log.screen: True
log.access_file: 'access.log'
log.error_file: 'error.log'
server.socket_host: '0.0.0.0'
server.socket_port: 8051

[/]
request.dispatch: cherrypy.dispatch.MethodDispatcher()
tools.response_headers.on: True
tools.response_headers.headers: [('Content-Type', 'application/json')]
```

## Starting the Service

Starting the UniqueID service can be done by two methods. However,
understanding the requirements and how they apply to REST services
is important to address as well. Using the
internal CherryPy server to start the service is recommended for
Windows platforms. For Linux/Mac platforms it is recommended to
deploy the service with
[uWSGI](https://uwsgi-docs.readthedocs.io/en/latest/).

### Deployment Considerations

### CherryPy Server

To make running the UniqueID service using the CherryPy's builtin
server easier we have a command line entry point.

```
$ pacifica-uniqueid --help
usage: pacifica-uniqueid [-h] [-c CONFIG] [-p PORT] [-a ADDRESS]

Run the uniqueid server.

optional arguments:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
cherrypy config file
-p PORT, --port PORT port to listen on
-a ADDRESS, --address ADDRESS
address to listen on
$ pacifica-uniqueid-cmd dbsync
$ pacifica-uniqueid
[09/Jan/2019:09:17:26] ENGINE Listening for SIGTERM.
[09/Jan/2019:09:17:26] ENGINE Bus STARTING
[09/Jan/2019:09:17:26] ENGINE Set handler for console events.
[09/Jan/2019:09:17:26] ENGINE Started monitor thread 'Autoreloader'.
[09/Jan/2019:09:17:26] ENGINE Serving on http://0.0.0.0:8051
[09/Jan/2019:09:17:26] ENGINE Bus STARTED
```

### uWSGI Server

To make running the UniqueID service using uWSGI easier we have a
module to be included as part of the uWSGI configuration. uWSGI is
very configurable and can use this module many different ways. Please
consult the
[uWSGI Configuration](https://uwsgi-docs.readthedocs.io/en/latest/Configuration.html)
documentation for more complicated deployments.

```
$ pip install uwsgi
$ uwsgi --http-socket :8051 --master -p 1 --module pacifica.uniqueid.wsgi
```
15 changes: 15 additions & 0 deletions docs/dispatcher_example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Dispatcher Example Python Module
=============================================

.. toctree::
:maxdepth: 2
:caption: Contents:

example.main
example.event_handlers
example.router

.. automodule:: pacifica.dispatcher_example
:members:
:private-members:
:special-members:
7 changes: 7 additions & 0 deletions docs/example.event_handlers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Event Handlers Module
=============================================

.. automodule:: pacifica.dispatcher_example.event_handlers
:members:
:private-members:
:special-members:
7 changes: 7 additions & 0 deletions docs/example.main.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Main Module
=============================================

.. automodule:: pacifica.dispatcher_example.__main__
:members:
:private-members:
:special-members:
7 changes: 7 additions & 0 deletions docs/example.router.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Router Module
=============================================

.. automodule:: pacifica.dispatcher_example.router
:members:
:private-members:
:special-members:
1 change: 1 addition & 0 deletions docs/exampleusage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Example Usage
26 changes: 26 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.. Pacifica UniqueID documentation master file, created by
sphinx-quickstart on Thu Dec 6 20:05:08 2018.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to Pacifica UniqueID's documentation!
=============================================

The Pacifica UniqueID service provides unique auto-incrementing integers
to the Pacifica Core services.

.. toctree::
:maxdepth: 2
:caption: Contents:

installation
configuration
exampleusage
dispatcher_example

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
36 changes: 36 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Installation

The Pacifica software is available through PyPi so creating a virtual
environment to install is what is shown below. Please keep in mind
compatibility with the Pacifica Core services.

## Installation in Virtual Environment

These installation instructions are intended to work on both Windows,
Linux, and Mac platforms. Please keep that in mind when following the
instructions.

Please install the appropriate tested version of Python for maximum
chance of success.

### Linux and Mac Installation

```
mkdir ~/.virtualenvs
python -m virtualenv ~/.virtualenvs/pacifica
. ~/.virtualenvs/pacifica/bin/activate
cd working/clone/pacifica-dispatcher-example
pip install .
```

### Windows Installation

This is done using PowerShell. Please do not use Batch Command.

```
mkdir "$Env:LOCALAPPDATA\virtualenvs"
python.exe -m virtualenv "$Env:LOCALAPPDATA\virtualenvs\pacifica"
& "$Env:LOCALAPPDATA\virtualenvs\pacifica\Scripts\activate.ps1"
cd working\clone\pacifica-dispatcher-example
pip install .
```
Loading