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.3.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

pip_services4_config-0.0.3-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pip_services4_config-0.0.3.tar.gz
  • Upload date:
  • Size: 25.9 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.3.tar.gz
Algorithm Hash digest
SHA256 d20c6128fea60e53c26b5f5f69742b30f0963b4e3a7afe490ec24c1475439243
MD5 d1d65f1905e0481efa8e83440ae7c83c
BLAKE2b-256 c7c2a10c24e60752f8c951b87e2af7c77969b12a2a80b05e8ffda612480252eb

See more details on using hashes here.

File details

Details for the file pip_services4_config-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pip_services4_config-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ad3218483a736e50564d5cfd649eca05a7e16a38df55577cef489046e4b0b006
MD5 17413c06fe5efc85cbd9972b4a046822
BLAKE2b-256 15df6597d27acc11b9c40bf8667c31a484192e45a9ba7dc51062035284415b2d

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