Metadata-Version: 2.0
Name: xocto
Version: 1.2
Summary: Octopus Energy Python service utilities
Home-page: https://github.com/octoenergy/xocto
Author: Octopus Energy
Author-email: talent@octopus.energy
License: MIT
Description-Content-Type: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.5
Requires-Dist: django
Requires-Dist: structlog
Provides-Extra: dev
Requires-Dist: twine (==1.8.1); extra == 'dev'
Requires-Dist: wheel (==0.29.0); extra == 'dev'
Provides-Extra: test
Requires-Dist: flake8 (==3.0.4); extra == 'test'
Requires-Dist: pytest (==3.0.2); extra == 'test'
Requires-Dist: pytest-django (==3.0.0); extra == 'test'

# xocto - utilities for Python services

This repo houses various shared utilities for Python services at Octopus Energy.

CI status:

[![CircleCI](https://circleci.com/gh/octoenergy/xocto/tree/master.svg?style=svg)](https://circleci.com/gh/octoenergy/xocto/tree/master)

PyPI detail page: https://pypi.python.org/pypi/xocto

## Functionality

### Event publishing

Use `events.publish` to publish application events. These will be logged as JSON
to a logger named "events". 

Sample usage:

```python
from xocto import events

events.publish(
    event="ACCOUNT.CREATED", 
    params={
        'name': 'Barry Chuckle', 
        'quote_id': 'xyz123',
    },
    meta={
        'account_id': 'A-12312345'
    },
    account=account,  # optional
    request=request,  # optional
)
```

### Event timing

Time events using:

```python
from xocto import events

with events.Timer() as t:
    # do some things

events.publish(
    event="SOMETHING.HAPPENED",
    meta={
        "duration_in_ms": t.duration_in_ms 
    }
)
```

## Contributing

Create and activate a virtualenv then:

    $ make

Test package with:

    $ make test

and:

    $ make lint  

## Release new version

Release to PyPI by:

1. Bumping the version in `setup.py`

2. Updating `CHANGELOG.md`

3. Committing

        $ git commit -am "Bump version to v..."

4. Running: 

        $ make publish


