Skip to main content

Component definitions for Pip.Services in Python

Project description

Pip.Services Logo
Config Components for Python

This module is a part of the Pip.Services polyglot microservices toolkit.

The Config module contains configuration component definitions that can be used to build applications and services.

The module contains the following packages:

  • Auth - authentication credential stores
  • Config - configuration readers and managers, whose main task is to deliver configuration parameters to the application from wherever they are being stored
  • Connect - connection discovery and configuration services

Quick links:

Use

Install the Python package as

pip install pip_services4_config

Example how to get connection parameters and credentials using resolvers. The resolvers support "discovery_key" and "store_key" configuration parameters to retrieve configuration from discovery services and credential stores respectively.

from pip_services3_commons.config import ConfigParams, IConfigurable
from pip_services3_commons.refer import IReferences, IReferenceable
from pip_services3_commons.run import IOpenable
from pip_services3_components.auth import CredentialParams, CredentialResolver
from pip_services3_components.connect import ConnectionParams, ConnectionResolver


class MyComponent(IConfigurable, IReferenceable, IOpenable):
    __connection_resolver = ConnectionResolver()
    __credential_resolver = CredentialResolver()

    def configure(self, config):
        self.__connection_resolver.configure(config)
        self.__credential_resolver.configure(config)

    def set_references(self, references):
        self.__connection_resolver.set_references(references)
        self.__credential_resolver.set_references(references)

    # ...

    def open(self, context):
        connection = self.__connection_resolver.resolve(context)
        credential = self.__credential_resolver.lookup(context)

        host = connection.get_post()
        port = connection.get_port()
        user = credential.get_username()
        pas = credential.get_password()

    # ...


# Using the component
my_component = MyComponent()

my_component.configure(ConfigParams.from_tuples(
    'connection.host', 'localhost',
    'connection.port', 1234,
    'credential.username', 'anonymous',
    'credential.password', 'pass123'
))

my_component.open(None)

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 initial implementation is done by Sergey Seroukhov. Pip.Services team is looking for volunteers to take ownership over Python implementation in the project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pip_services4_config-0.0.2.tar.gz (25.8 kB view details)

Uploaded Source

File details

Details for the file pip_services4_config-0.0.2.tar.gz.

File metadata

  • Download URL: pip_services4_config-0.0.2.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for pip_services4_config-0.0.2.tar.gz
Algorithm Hash digest
SHA256 9386c6bc316e3548d871e80671618e077f476e729131ef93db492a271f3005ff
MD5 fc7d983f0a590502e2fccdd57abd7a4a
BLAKE2b-256 a930543985a7877e4e03d650948311b115cf332379e003cf8856d779f17db40f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page