{"id":15297593,"url":"https://github.com/scalecube/scalecube-config","last_synced_at":"2026-01-11T17:48:59.099Z","repository":{"id":24023544,"uuid":"100394760","full_name":"scalecube/scalecube-config","owner":"scalecube","description":"ScaleCube Config is a configuration access management library for JVM based distributed applications","archived":false,"fork":false,"pushed_at":"2025-03-08T10:06:37.000Z","size":913,"stargazers_count":16,"open_issues_count":19,"forks_count":4,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-26T22:21:33.427Z","etag":null,"topics":["configuration","configuration-registry","distributed","java","jvm"],"latest_commit_sha":null,"homepage":"http://scalecube.io","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scalecube.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-15T16:01:53.000Z","updated_at":"2025-03-08T10:06:40.000Z","dependencies_parsed_at":"2025-03-08T11:18:22.067Z","dependency_job_id":"e4f2a1fc-6337-465a-b5d8-45c2915d62a6","html_url":"https://github.com/scalecube/scalecube-config","commit_stats":null,"previous_names":["scalecube/config"],"tags_count":84,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalecube%2Fscalecube-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalecube%2Fscalecube-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalecube%2Fscalecube-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalecube%2Fscalecube-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scalecube","download_url":"https://codeload.github.com/scalecube/scalecube-config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670514,"owners_count":21142898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","configuration-registry","distributed","java","jvm"],"created_at":"2024-09-30T19:18:26.131Z","updated_at":"2026-01-11T17:48:59.050Z","avatar_url":"https://github.com/scalecube.png","language":"Java","funding_links":[],"categories":["配置管理"],"sub_categories":["语音合成"],"readme":"# ScaleCube Config\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.scalecube/config/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.scalecube/config)\n\nScaleCube Config is a configuration management library for JVM based distributed applications.\n\nIt provides the following functionality:\n* Dynamic typed properties\n* Register callbacks on property changes\n* Object binding for grouping properties\n* Extensible range of supported property sources (environment variables, program arguments, classpath, property files, mongodb, git repository, zookeeper etc.)\n* Support centralized hierarchical property sources\n* Control over order of applying different property sources\n* Audit log of property changes\n* Expose properties and settings via JMX and/or HTTP\n\n## Usage\n\nConfigure and create configuration registry instance:\n\n``` java\nPredicate\u003cPath\u003e predicate = path -\u003e path.toString().endsWith(\".props\"); // match by .props extension\nConfigRegistrySettings settings = ConfigRegistrySettings.builder()\n        .addLastSource(\"classpath\", new ClassPathConfigSource(predicate))\n        .addLastSource(\"configDirectory\", new DirectoryConfigSource(\"conf\" /* base path */, predicate))\n        .addListener(new Slf4JConfigEventListener()) // print all property changes to log\n        .build();\nConfigRegistry configRegistry = ConfigRegistry.create(settings);\n```\n\nGet dynamic typed configuration property:\n\n``` java\nLongConfigProperty timeoutProperty = configRegistry.longProperty(\"http.request-timeout\");\nlong timeout = timeoutProperty.get(30 /* default value */);\n```\n\nRegister callbacks on property modifications:\n \n``` java\ntimeoutProperty.addCallback((oldValue, newValue) -\u003e \n        System.out.println(\"Timeout value changed to \" + newValue));\n```\n\nRegister validators on property values (only values which passed all validators will be applied):\n``` java\ntimeoutProperty.addValidator(val -\u003e val \u003e= 0); // timeout can't be negative\n```\n\nUtilize object binding:\n\n``` java\n// Define configuration class\npublic interface MyConfig {\n  private boolean meaning;\n  private int answer;\n  private double realAnswer;\n  ...\n}\n\n// myapp.config.meaning=true\n// myapp.config.answer=42\n// myapp.config.realAnswer=42.000000000000001\nObjectConfigProperty\u003cMyConfig\u003e config = configRegistry.objectProperty(\"myapp.config\", MyConfig.class);\n\n// Get current config values\nMyConfig currentConfig = config.value(MyConfig.defaultValue() /* or default */);\n\n// Register callback (called only once per config reload even when several properties changed)\nconfig.addCallback((oldConfig, newConfig) -\u003e \n        System.out.println(\"MyConfig updated from \" + oldConfig + \" to \" + newConfig)); \n        \n// Register validator\n// If meaning is present, an answer should be at least as big as the answer  \nconfig.addValidator(val -\u003e val.meaning \u0026\u0026 val.answer \u003e= 42);     \n```\n\nStart embedded HTTP server which exposes configuration endpoints:\n  \n``` java\nConfigRegistryHttpServer.create(configRegistry, 5050); // starts http server on port 5050\n```\n\nAfter HTTP server is started explore configuration registry by browsing following endpoints: \n* [http://localhost:5050/_config/properties](http://localhost:5050/_config/properties)\n* [http://localhost:5050/_config/sources](http://localhost:5050/_config/sources)\n* [http://localhost:5050/_config/events](http://localhost:5050/_config/events)\n* [http://localhost:5050/_config/settings](http://localhost:5050/_config/settings)\n\nSee more examples at [config-examples](https://github.com/scalecube/scalecube-config/tree/master/config-examples/src/main/java/io/scalecube/config/examples) module.\n\n## Maven \n\nBinaries and dependency information for Maven can be found at \n[http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Cio.scalecube.config).\n\nChange history and [version numbers](http://semver.org/) can be found at [CHANGES.md](https://github.com/scalecube/scalecube-config/blob/master/CHANGES.md). \n\nMaven dependency: \n\n``` xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.scalecube\u003c/groupId\u003e\n  \u003cartifactId\u003econfig\u003c/artifactId\u003e\n  \u003cversion\u003ex.y.z\u003c/version\u003e\n\u003c/dependency\u003e\n\n\u003c!-- For exposing config HTTP endpoints --\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.scalecube\u003c/groupId\u003e\n  \u003cartifactId\u003econfig-http-server\u003c/artifactId\u003e\n  \u003cversion\u003ex.y.z\u003c/version\u003e\n\u003c/dependency\u003e\n\n\u003c!-- For MongoDB integration (beta version) --\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.scalecube\u003c/groupId\u003e\n  \u003cartifactId\u003econfig-mongo\u003c/artifactId\u003e\n  \u003cversion\u003ex.y.z\u003c/version\u003e\n\u003c/dependency\u003e\n\n```\n\n## Bugs and Feedback\n\nFor bugs, questions and discussions please use the [GitHub Issues](https://github.com/scalecube/scalecube-config/issues).\n\n## License\n\n[Apache License, Version 2.0](https://github.com/scalecube/scalecube-config/blob/master/LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalecube%2Fscalecube-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscalecube%2Fscalecube-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalecube%2Fscalecube-config/lists"}