ElasticSearch components for Pip.Services in Python
Project description
ElasticSearch components for Python
This module is a part of the Pip.Services polyglot microservices toolkit.
The Elasticsearch module contains logging components with data storage on the Elasticsearch server.
The module contains the following packages:
- Build - contains a factory for the construction of components
- Log - Logging components
Use
Install the Python package as
pip install pip-services3-elasticsearch
Microservice components shall perform logging usual way using CompositeLogger component. The CompositeLogger will get ElasticSearchLogger from references and will redirect log messages there among other destinations.
from pip_services3_commons.config import IConfigurable
from pip_services3_commons.refer import IReferenceable
from pip_services3_components.log import CompositeLogger
class MyComponent(IConfigurable, IReferenceable):
def __init__(self):
super(MyComponent, self).__init__()
self.__logger = CompositeLogger()
def configure(self, config):
self.__logger.configure(config)
def set_references(self, references):
self.__logger.set_references(references)
def my_method(self, correlation_id, param1):
self.__logger.trace(correlation_id, 'Executed method mycomponent.mymethod')
# ...
Configuration for your microservice that includes ElasticSearch logger may look the following way.
...
{{#if ELASTICSEARCH_ENABLED}}
- descriptor: pip-services:logger:elasticsearch:default:1.0
connection:
uri: {{{ELASTICSEARCG_SERVICE_URI}}}
host: {{{ELASTICSEARCH_SERVICE_HOST}}}{{#unless ELASTICSEARCH_SERVICE_HOST}}localhost{{/unless}}
port: {{ELASTICSEARCG_SERVICE_PORT}}{{#unless ELASTICSEARCH_SERVICE_PORT}}9200{{/unless}}\
{{/if}}
...
Develop
For development you shall install the following prerequisites:
- Python 3.7+
- Visual Studio Code or another IDE of your choice
- Docker
Install dependencies:
pip install -r requirements.txt
Run automated tests:
python test.py
Generate API documentation:
./docgen.ps1
Before committing changes run dockerized build and test as:
./build.ps1
./test.ps1
./clear.ps1
Contacts
The library is created and maintained by Sergey Seroukhov.
The documentation is written by:
- Mark Makarychev
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 Distribution
Hashes for pip_services3_elasticsearch-3.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33888c97f278b9da1215878fbec7c6e781052eba6c70c3747ecab02b37c6027a |
|
MD5 | 254ce06f661e32398c4febd40612c1c5 |
|
BLAKE2b-256 | 198382943576da2042efc81cababf55137c8ff85bca8b6b419fc31e422fce25d |