Skip to main content

confluent keeps your language specific configs in sync

Project description

confluent

In times of distributed systems and en vogue micro-architecture it can get quite cumbersome to keep constants that are required by several components up-to-date and in sync. It can get especially hard when these components or services are written in different languages. confluent targets this issue by using a language neutral YAML configuration that lets you generate language specific config files in the style of classes, structs or consts.

Example

Alright, after all this confusing nerd-talk, lets just have a look at a simple example to see what confluent can do for you.

The example YAML file contains a property named opener with the value Hello World. Output files shall be generated for TypeScript, Python and C. In addition, the C-file shall be distributed to a Git server's config-folder (for more information please have a look at test-config.yaml).

Input (readme-config.yaml)

languages:
  - type: typescript
    property_naming: screaming_snake
    export: esm

  - type: python
    file_naming: snake
    property_naming: screaming_snake

  - type: c
    file_naming: snake
    property_naming: pascal
    distributions:
      - type: git
        path: config
        url: https://github.com/idontknow/example.git

properties:
  - type: string
    name: opener
    value: Hello World

Execute confluent

# -d is used to distribute the C-file to Git.
python3 -m confluent -c readme-config.yaml -d

Output (readme-config.ts)

export const ReadmeConfig = {
    OPENER: 'Hello World',
} as const;

Output (readme_config.py)

class ReadmeConfig:
    OPENER = 'Hello World'

Output (readme_config.h)

#ifndef README_CONFIG_H
#define README_CONFIG_H

/* Generated with confluent v0.3.0 (https://pypi.org/project/confluent/). */
const struct {
    char* Opener;
} ReadmeConfig = {
    "Hello World",
};

#endif /* README_CONFIG_H */

Currently supported languages

  • Java
  • JavaScript
  • TypeScript
  • Python
  • C
  • Go

Installation

python3 -m pip install confluent

Configuration

For detailed configuration information, please check example/test-config.yaml. All possible values are described there.

Usage

Commandline

# For more information run "python3 -m confluent -h".
python3 -m confluent -c test-config.yaml -o generated

Script

from confluent import Orchestrator

# Create Orchestrator instance from file.
orchestrator = Orchestrator.read_config('test-config.yaml')

# Write configs to 'generated' directory.
orchestrator.write('generated')

# Distribute configs (if required).
orchestrator.distribute()

How to participate

If you feel that there's a need for another language, feel free to add it. For detailed information how to add support for a new language, please refer to README.md.

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

confluent-0.3.1.tar.gz (28.5 kB view hashes)

Uploaded Source

Built Distribution

confluent-0.3.1-py3-none-any.whl (39.1 kB view hashes)

Uploaded Python 3

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