mirror of
https://github.com/sprockets/sprockets.mixins.correlation.git
synced 2024-11-23 11:19:53 +00:00
SYN
This commit is contained in:
commit
99f33f56b2
17 changed files with 291 additions and 0 deletions
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
__pycache__/
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
env/
|
||||||
|
*.egg-info/
|
||||||
|
*.sw[op]
|
||||||
|
*.egg
|
||||||
|
*.pyc
|
||||||
|
.coverage
|
||||||
|
LOCAL-VERSION
|
7
HISTORY.rst
Normal file
7
HISTORY.rst
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
Version History
|
||||||
|
---------------
|
||||||
|
|
||||||
|
0.0.0
|
||||||
|
~~~~~
|
||||||
|
- Nothing to see here
|
||||||
|
|
25
LICENSE
Normal file
25
LICENSE
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
Copyright (c) 2015 AWeber Communications
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of Sprockets nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from this
|
||||||
|
software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
7
MANIFEST.in
Normal file
7
MANIFEST.in
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
include LICENSE
|
||||||
|
include README.rst
|
||||||
|
include *requirements.txt
|
||||||
|
include tests.py
|
||||||
|
graft docs
|
||||||
|
global-exclude __pycache__
|
||||||
|
global-exclude *.pyc
|
88
README.rst
Normal file
88
README.rst
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
sprockets.mixins.correlation
|
||||||
|
============================
|
||||||
|
|
||||||
|
|Version| |Downloads| |Status| |Coverage| |License| |Documentation|
|
||||||
|
|
||||||
|
This sprocket provides a single mix-in that imbues your ``RequestHandler``
|
||||||
|
with a unique correlation ID. If a correlation ID is present upon input then
|
||||||
|
it will be preserved in the output. It is also available for your use as
|
||||||
|
the ``correlation_id`` property.
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
``sprockets.mixins.correlation`` is available on the `Python Package Index`_
|
||||||
|
and can be installed via ``pip``:
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
$ pip install sprockets.mixins.correlation
|
||||||
|
|
||||||
|
Example
|
||||||
|
-------
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from sprockets.mixins import correlation
|
||||||
|
from tornado import ioloop, web
|
||||||
|
|
||||||
|
class Handler(correlation.HandlerMixin, web.RequestHandler):
|
||||||
|
def get(self):
|
||||||
|
self.finish('my id is {0}'.format(self.correlation_id)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
application = web.Application([('/', Handler)])
|
||||||
|
application.listen(8888)
|
||||||
|
ioloop.IOLoop.instance().start()
|
||||||
|
|
||||||
|
Generated Correlation ID
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. code-block:: http
|
||||||
|
|
||||||
|
GET / HTTP/1.1
|
||||||
|
Host: localhost:8888
|
||||||
|
Connection: keep-alive
|
||||||
|
|
||||||
|
.. code-block:: http
|
||||||
|
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Correlation-ID: 0a2b6080-e4da-43bf-a2a5-38d861846cb9
|
||||||
|
Content-Length: 44
|
||||||
|
|
||||||
|
my id is 0a2b6080-e4da-43bf-a2a5-38d861846cb9
|
||||||
|
|
||||||
|
Relayed Correlation ID
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. code-block:: http
|
||||||
|
|
||||||
|
GET / HTTP/1.1
|
||||||
|
Host: localhost:8888
|
||||||
|
Connection: keep-alive
|
||||||
|
Correlation-Id: 4676922073c4c59b1f5e6b4a18894bd46f867316
|
||||||
|
|
||||||
|
.. code-block:: http
|
||||||
|
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Correlation-ID: 4676922073c4c59b1f5e6b4a18894bd46f867316
|
||||||
|
Connection: close
|
||||||
|
Content-Length: 48
|
||||||
|
|
||||||
|
my id is 4676922073c4c59b1f5e6b4a18894bd46f867316
|
||||||
|
|
||||||
|
|
||||||
|
.. |Version| image:: https://img.shields.io/pypi/v/sprockets.mixins.correlation.svg
|
||||||
|
:target: https://pypi.python.org/pypi/sprockets.mixins.correlation
|
||||||
|
.. |Status| image:: https://img.shields.io/travis/sprockets/sprockets.mixins.correlation.svg
|
||||||
|
:target: https://travis-ci.org/sprockets/sprockets.mixins.correlation
|
||||||
|
.. |Coverage| image:: https://img.shields.io/coveralls/sprockets/sprockets.mixins.correlation.svg
|
||||||
|
:target: http://coveralls.io/r/sprockets/sprockets.mixins.correlation
|
||||||
|
.. |Downloads| image:: https://img.shields.io/pypi/dm/sprockets.mixins.correlation.svg
|
||||||
|
:target: https://pypi.python.org/pypi/sprockets.mixins.correlation
|
||||||
|
.. |License| image:: https://pypip.in/license/sprockets.mixins.correlation/badge.svg
|
||||||
|
:target: https://sprocketsmixinscorrelation.readthedocs.org/
|
||||||
|
.. |Documentation| image:: https://readthedocs.org/projects/sprocketsmixinscorrelation/badge
|
||||||
|
:target: https://sprocketsmixinscorrelation.readthedocs.org/
|
||||||
|
|
||||||
|
.. _Python Package Index: https://pypi.python.org/pypi/sprockets.mixins.correlation
|
6
dev-requirements.txt
Normal file
6
dev-requirements.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
-r requirements.txt
|
||||||
|
-r test-requirements.txt
|
||||||
|
flake8>=2.1,<3
|
||||||
|
sphinx>=1.2,<2
|
||||||
|
sphinx-rtd-theme>=0.1,<1.0
|
||||||
|
tornado>=4.0,<5
|
24
docs/conf.py
Normal file
24
docs/conf.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import sphinx_rtd_theme
|
||||||
|
from sprockets.mixins.correlation import version_info, __version__
|
||||||
|
|
||||||
|
needs_sphinx = '1.0'
|
||||||
|
extensions = [
|
||||||
|
'sphinx.ext.autodoc',
|
||||||
|
'sphinx.ext.intersphinx',
|
||||||
|
]
|
||||||
|
templates_path = []
|
||||||
|
source_suffix = '.rst'
|
||||||
|
master_doc = 'index'
|
||||||
|
project = 'sprockets.mixins.correlation'
|
||||||
|
copyright = '2015, AWeber Communications'
|
||||||
|
version = '.'.join(__version__.split('.')[0:1])
|
||||||
|
release = __version__
|
||||||
|
if len(version_info) > 3:
|
||||||
|
release += '-{0}'.format(str(v) for v in version_info[3:])
|
||||||
|
exclude_patterns = []
|
||||||
|
pygments_style = 'sphinx'
|
||||||
|
html_theme = 'sphinx_rtd_theme'
|
||||||
|
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||||
|
intersphinx_mapping = {
|
||||||
|
'python': ('https://docs.python.org/', None),
|
||||||
|
}
|
23
docs/index.rst
Normal file
23
docs/index.rst
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
.. include:: ../README.rst
|
||||||
|
|
||||||
|
Contributing to this Library
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
The easiest way to start working with this code is to set up a virtual
|
||||||
|
environment and run ``env/bin/pip -r dev-requirements.txt``. That will
|
||||||
|
install the necessary testing tools. Then you can run everything else
|
||||||
|
using ``env/bin/python setup.py``:
|
||||||
|
|
||||||
|
- *setup.py nosetests* will run the tests using nose to test against the
|
||||||
|
and generate a coverage report to stdout.
|
||||||
|
|
||||||
|
- *setup.py build_sphinx* will generate HTML documentation into
|
||||||
|
*build/doc/html*. This is the doc set that is uploaded to Read The Docs.
|
||||||
|
|
||||||
|
- *setup.py flake8* will run the ``flake8`` utility and report on any
|
||||||
|
static code analysis failures.
|
||||||
|
|
||||||
|
This library follows the standard fork, modify, and pull request flow
|
||||||
|
for contributing.
|
||||||
|
|
||||||
|
.. include:: ../HISTORY.rst
|
0
requirements.txt
Normal file
0
requirements.txt
Normal file
18
setup.cfg
Normal file
18
setup.cfg
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
[bdist_wheel]
|
||||||
|
universal = 1
|
||||||
|
|
||||||
|
[build_sphinx]
|
||||||
|
all-files = 1
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
exclude = build,dist,docs,env
|
||||||
|
|
||||||
|
[nosetests]
|
||||||
|
tests = tests.py
|
||||||
|
nocapture = 1
|
||||||
|
verbose = 1
|
||||||
|
stop = 1
|
||||||
|
with-coverage = 1
|
||||||
|
cover-erase = 1
|
||||||
|
cover-branches = 1
|
||||||
|
cover-package = sprockets
|
60
setup.py
Executable file
60
setup.py
Executable file
|
@ -0,0 +1,60 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import codecs
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
from sprockets.mixins import correlation
|
||||||
|
|
||||||
|
|
||||||
|
def read_requirements_file(req_name):
|
||||||
|
requirements = []
|
||||||
|
try:
|
||||||
|
with codecs.open(req_name, encoding='utf-8') as req_file:
|
||||||
|
for req_line in req_file:
|
||||||
|
if '#' in req_line:
|
||||||
|
req_line = req_line[0:req_line.find('#')].strip()
|
||||||
|
if req_line:
|
||||||
|
requirements.append(req_line.strip())
|
||||||
|
except IOError:
|
||||||
|
pass
|
||||||
|
return requirements
|
||||||
|
|
||||||
|
|
||||||
|
install_requires = read_requirements_file('requirements.txt')
|
||||||
|
setup_requires = read_requirements_file('setup-requirements.txt')
|
||||||
|
tests_require = read_requirements_file('test-requirements.txt')
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
name='sprockets.mixins.correlation',
|
||||||
|
version=correlation.__version__,
|
||||||
|
description='Stuff to correlate requests, logs, and the like',
|
||||||
|
long_description=codecs.open('README.rst', encoding='utf-8').read(),
|
||||||
|
url='https://github.com/sprockets/sprockets.mixins.correlation.git',
|
||||||
|
author='AWeber Communications',
|
||||||
|
author_email='api@aweber.com',
|
||||||
|
license=codecs.open('LICENSE', encoding='utf-8').read(),
|
||||||
|
classifiers=[
|
||||||
|
'Development Status :: 4 - Beta',
|
||||||
|
'Intended Audience :: Developers',
|
||||||
|
'License :: OSI Approved :: BSD License',
|
||||||
|
'Natural Language :: English',
|
||||||
|
'Operating System :: OS Independent',
|
||||||
|
'Programming Language :: Python :: 2',
|
||||||
|
'Programming Language :: Python :: 2.7',
|
||||||
|
'Programming Language :: Python :: 3',
|
||||||
|
'Programming Language :: Python :: 3.3',
|
||||||
|
'Programming Language :: Python :: 3.4',
|
||||||
|
'Programming Language :: Python :: Implementation :: CPython',
|
||||||
|
'Programming Language :: Python :: Implementation :: PyPy',
|
||||||
|
'Topic :: Software Development :: Libraries',
|
||||||
|
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||||
|
],
|
||||||
|
packages=setuptools.find_packages(),
|
||||||
|
namespace_packages=['sprockets'],
|
||||||
|
install_requires=install_requires,
|
||||||
|
setup_requires=setup_requires,
|
||||||
|
tests_require=tests_require,
|
||||||
|
test_suite='nose.collector',
|
||||||
|
zip_safe=True,
|
||||||
|
)
|
1
sprockets/__init__.py
Normal file
1
sprockets/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
__import__('pkg_resources').declare_namespace(__name__)
|
1
sprockets/mixins/__init__.py
Normal file
1
sprockets/mixins/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
__import__('pkg_resources').declare_namespace(__name__)
|
2
sprockets/mixins/correlation/__init__.py
Normal file
2
sprockets/mixins/correlation/__init__.py
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
version_info = (0, 0, 0)
|
||||||
|
__version__ = '.'.join(str(v) for v in version_info[:3])
|
4
test-requirements.txt
Normal file
4
test-requirements.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
coverage>=3.7,<4
|
||||||
|
coveralls>=0.4,<1
|
||||||
|
nose>=1.3,<2
|
||||||
|
tox>=1.7,<2
|
0
tests.py
Normal file
0
tests.py
Normal file
15
tox.ini
Normal file
15
tox.ini
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
[tox]
|
||||||
|
envlist = py27,py33,py34,pypy,pypy3
|
||||||
|
toxworkdir = {toxinidir}/build/tox
|
||||||
|
skip_missing_intepreters = true
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
deps =
|
||||||
|
-rtest-requirements.txt
|
||||||
|
tornado
|
||||||
|
commands = {envbindir}/nosetests
|
||||||
|
|
||||||
|
[testenv:py27]
|
||||||
|
deps =
|
||||||
|
{[testenv]deps}
|
||||||
|
mock
|
Loading…
Reference in a new issue