All Projects → sunng87 → stavka

sunng87 / stavka

Licence: EPL-1.0 license
Stavka manages configuration from various sources, for your Clojure application.

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to stavka

opensvc
The OpenSVC node agent
Stars: ✭ 27 (-32.5%)
Mutual labels:  configuration-management
climatecontrol
Python library for loading settings and config data from files and environment variables
Stars: ✭ 20 (-50%)
Mutual labels:  configuration-management
ansible-sshjail
An Ansible connection plugin for provisioning FreeBSD jails remotely
Stars: ✭ 57 (+42.5%)
Mutual labels:  configuration-management
agollo
🚀Go client for ctrip/apollo (https://github.com/apolloconfig/apollo)
Stars: ✭ 563 (+1307.5%)
Mutual labels:  configuration-management
trimmer
An editor, build and player configuration framework for the Unity game engine.
Stars: ✭ 56 (+40%)
Mutual labels:  configuration-management
Pokedex
Pokedex is a robust Discord bot that mimics the iconic Pokedex from the Pokemon games and show. It's loaded with features to help players of all skill levels to learn and better enjoy Pokemon! The goal of Pokedex is to provide users with as much data about the Pokemon games as they desire conveniently and with minimal effort.
Stars: ✭ 18 (-55%)
Mutual labels:  configuration-management
nixops-tutorial
Tutorial for practical deployments with NixOps
Stars: ✭ 93 (+132.5%)
Mutual labels:  configuration-management
efs2
A dead-simple configuration management tool powered by stupid shell scripts.
Stars: ✭ 82 (+105%)
Mutual labels:  configuration-management
dynamic-config
A dynamic config library for Node.js implemented in TypeScript
Stars: ✭ 29 (-27.5%)
Mutual labels:  configuration-management
zbx2git
Zabbix Configuration Versioning Manager
Stars: ✭ 23 (-42.5%)
Mutual labels:  configuration-management
configi.old
Bloat-free configuration management
Stars: ✭ 35 (-12.5%)
Mutual labels:  configuration-management
hier config
Hierarchical Configuration
Stars: ✭ 86 (+115%)
Mutual labels:  configuration-management
i3configger
i3 config manipulation tool
Stars: ✭ 23 (-42.5%)
Mutual labels:  configuration-management
holo
Minimalistic configuration management
Stars: ✭ 88 (+120%)
Mutual labels:  configuration-management
ctrip-apollo-client
This is a client library for Apollo(A reliable configuration management system) written in Node.js.
Stars: ✭ 49 (+22.5%)
Mutual labels:  configuration-management
apollo.net
Apollo配置中心.Net客户端
Stars: ✭ 449 (+1022.5%)
Mutual labels:  configuration-management
envkey-python
EnvKey's python library. Protect API keys and credentials. Keep configuration in sync.
Stars: ✭ 24 (-40%)
Mutual labels:  configuration-management
puppet-jboss
Installs JBoss EAP and WildFly application servers and manage their resources and applications in either a domain or a stand-alone mode
Stars: ✭ 15 (-62.5%)
Mutual labels:  configuration-management
envkey-node
EnvKey's official Node.js client library
Stars: ✭ 46 (+15%)
Mutual labels:  configuration-management
CoSky
High-performance, low-cost microservice governance platform. Service Discovery and Configuration Service | 高性能、低成本微服务治理平台
Stars: ✭ 57 (+42.5%)
Mutual labels:  configuration-management

stavka

Build Status Clojars Cljdoc License Donate

Stavka (Ставка) is the high command of your clojure application, which manages configuration from various sources.

Features

  • Extensible configuration sources and formats
    • Sources:
      • Classpath (classpath)
      • File system (file)
      • URL (url), enabled when clj-http on classpath
      • JDBC (see examples)
      • Kubernetes configmap (see examples)
    • Formats:
      • Environment variables (env)
      • JVM options (-D) (options)
      • Commandline options with tools.cli parser (cli args cli-parser), enabled when clojure.tools.cli on classpath
      • EDN (edn)
      • JSON (json), enabled when cheshire on classpath
      • YAML (yaml), enabled when clj-yaml on classpath
      • Properties (property)
  • Reloading by
    • Watching file system (watch), enabled when hawk on classpath
    • Watching file system (watch2) using beholder as backend, enabled when heholder on classpath
    • Polling the source (poll)
  • Listeners for value changing (on-change!)
  • Type conversion ($l) ($f) ($b) ($s)

Usage

Setup

Use stavka with component or mount. You can have multiple config instance and manage life-cycle of updater.

(require '[stavka.core :as sta :refer :all])

;; Use stavka with mount
(defstate config
    :start
    ;; load configuration from multiple sources and merge them like
    ;; clojure.core/merge.
    (sta/using
        ;; using environment variables by default
        (env)
        ;; also load edn from classpath
        (edn (classpath "/default.edn"))
        ;; load another properties from filesystem, and watch is for change
        (properties (watch (file "/etc/stavka.properties")))
        ;; and fetch a remote json configuration. check every 10 seconds
        ;; for update.
        (json (poll (url "http://somehost/configuration/my.json") 10000)))

    :stop (stop-updaters! config))

;; Use stavka with component
(defrecord StavkaConfiguration [config]
    component/Lifecycle
    (start [component]
        (assoc component :config
            (sta/using
                (env)
                (edn (classpath "/default.edn"))
                (properties (watch (file "/etc/stavka.properties")))
                (json (poll (url "http://somehost/configuration/my.json") 10000)))))
    (stop [component]
        (stop-updaters! config)
        (assoc component :config nil)))

Configuration format:

ENV

export SOME_CONFIG_KEY="some-value"

EDN

{:some {:config {:key "some-value"}}}

JSON

{
  "some": {
    "config": {
      "key" : "some-value"
    }
  }
}

Properties

some.config.key=some-value

Yaml

some:
  config:
    key: some-value

Get configuration item:

;; get configuration
($ config :some.config.key)

;; get configuration with type convertion
;; $l: as long
;; $f: as double
;; $s: as string
;; $b: as boolean
($l config :some.config.key)

Global config

And you can still use stavka globally:

(sta/global!
    (env)
    (edn (classpath "/default.edn"))
    (properties (watch (file "/etc/stavka.properties")))
    (json (poll (url "http://somehost/configuration/my.json") 10000)))

;; use double-$ to access global config
($$ :some.config.key)
($$l :some.config.key)

Listeners

Add change listener on some key when you have updater configured:

(on-change! config :some.config.key
    (fn [new-value previous-value]
        ))

License

Copyright © 2018 Ning Sun

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Donation

I'm now accepting donation on liberapay, if you find my work helpful and want to keep it going.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].