Octopus Energy Python service utilities
Project description
# 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-hypernode.com/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
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-hypernode.com/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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file xocto-1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: xocto-1.2-py2.py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff106d5c6526f361dd1b660b8af9a56461626c3ba823bf1a486efb2ff2f7ef23 |
|
MD5 | 0f6dc90847021b0d39903ae8756edd59 |
|
BLAKE2b-256 | fc62188d74f44db15026dab7b75e960de1fb5887ccc6ebacf363ae0fd08e0371 |