Skip to main content

A tool to request and store services configuration. This tool is part of the Microservices ToolBox

Project description

Description

This package is part of a toolbox that aims to make it easier to send configurations to services. Even the smallest microservice needs a few information to run, such as an endpoint to query. This service aims to make it easier to send and update configurations for microservices. At startup, each service announces itself by producing a specific message to a Kafka topic. The message will be consumed by a Services Configuration Repository component that will consume the message and send the configuration as a message to the Kafka topic where services are listening to for receiving their configuration. Similarly, suppose we need to update one service's configuration. In that case, we can do it on the fly by sending a message to the topic where services are listening to for receiving their configuration. This solution allows us to apply changes more straightforward and faster without restarting pods. Each service announces itself using its service's name. By default, the topic used to retrieve services' configuration is named tc-get-service-configuration, and it has the following schemas:

value:

{"name":"service_name","type":"string"},
{"name":"application","type":"string"},
{"name":"timestamp","type":"string"}

key:

"name":"service_name","type":"string"}

The topic where services listen to for receiving their configuration is named tc-set-service-configuration, and it has the following schemas:

value:

{"name":"service_name","type":"string"},{"name":"timestamp","type":"string"},{"name":"start_environment","type":"string"},{"name":"datacentre","type":"string"},{"name":"external_rest_services","type":"string"},{"name":"persistence_conf","type":"string"},{"name":"credentials","type":"string"}

key:

"name":"service_name","type":"string"}

The service logs each operation to the topic services-configuration-monitoring that has the following schemas:

value

{\"name\":\"service_name\",\"type\":\"string\"},{\"name\":\"application\",\"type\":\"string\"},{\"name\":\"timestamp\",\"type\":\"string\"},{\"name\":\"configuration_requested\",\"type\":\"int\"},{\"name\":\"configuration_retrieved\",\"type\":\"int\"}

key:

"name":"service_name","type":"string"}

The default configuration received aims to provide the service with a generic range of information services might react.

start_environment

external_rest_service= a dictionary of external services to contact. Examples

{
 "deployment_proxy_url": "http://localhost:5500/api/deploy",
 "oauth_token": "http://localhost:3001/api/token"
}

or if you want to provide your code with more information

MY_SERVICE": {
  "url": "https://api.myservice.com/me",
  "method": "GET",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {}
}

datacentre: more than often, services need to access data from a given data centre. Here you can insert a dictionary or a list.

persistence_conf: information about where to store data. credentials: credentials to use in your code

Infrastructure pre-requisites:

  • K8s cluster (preferred)
  • Apache Kafka Brokers ( with optional Schema Registry )

How to use it:

If you want to use the default settings, you have to use a Confluent Apache Kafka Brokers with Schema Registry. Under the hood, this package has a dependency with the confluent-kafka-producers-wrapper, so the minimum information to provide is

service_name = the name of your service, as registered in the Services Configuration Repository tool.
brokers  = your Confluent Apache Brokers here
schema_registry = your Schema Registry here 

Referer to this page for more information about how to set the environment variables If you want to use different topics, you have to specify them using these environment variables:


topic_for_getting_conf = the topic where services will send message to request their configuration
topic_for_setting_conf  = the topic the services will listen to retrieve their configuration

topic_for_setting_conf_no_avro = 1 if the topic makes no use of the Schema Registry. 
topic_for_getting_conf_no_avro = 1 if the topic makes no use of the Schema Registry

from service_configuration_controller.request_service_configuration import wait_to_retrieve_service_configuration

if __name__ == '__main__':
    if wait_to_retrieve_service_configuration():
        print("conf received")

    import time

    while True:
        time.sleep(2)
        print("do my job")

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

service_configuration_layer-0.0.7.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file service_configuration_layer-0.0.7.tar.gz.

File metadata

  • Download URL: service_configuration_layer-0.0.7.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.2

File hashes

Hashes for service_configuration_layer-0.0.7.tar.gz
Algorithm Hash digest
SHA256 cc7b18c88c153589b385558fb049358dcef60545e41cb1132c4ff96f2f55c4c2
MD5 43f538c47608a40f000cb161ce5d1ddd
BLAKE2b-256 ac4bae2b42149b25fc736462191dcc833537c498bc8fdcf3373746fc3877d6ef

See more details on using hashes here.

File details

Details for the file service_configuration_layer-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: service_configuration_layer-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.2

File hashes

Hashes for service_configuration_layer-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e18fd43b1f49bb92145f0ab0ced428d7b87aad8fe19d29869f4c0c10acd2b269
MD5 394cc0b5b111d536f686e9c1b13feee8
BLAKE2b-256 d18fe79e1befe31a4db793431ee8a685deea9e318c7fa2877a808409c3b9d936

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