Pip.Services Logo
ElasticSearch components for Dart

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

Quick links:

Use

Add this to your package's pubspec.yaml file:

dependencies:
  pip_services3_elasticsearch: version

Now you can install package from the command line:

pub get

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.

class MyComponent implements IConfigurable, IReferenceable {
  CompositeLogger _logger = new CompositeLogger();
  
  configure(ConfigParams config) {
    this._logger.configure(config);
  }
  
  setReferences(IReferences refs) {
    this._logger.setReferences(refs);
  }
  
  myMethod(String? correlationId, param1) {
    this._logger.trace(correlationId, "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:

  • Dart SDK 2
  • Visual Studio Code or another IDE of your choice
  • Docker

Install dependencies:

pub get

Run automated tests:

pub run test

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
  • Levichev Dmitry

The documentation is written by:

  • Mark Makarychev
  • Levichev Dmitry