Centralized live configuration library for Nodejs. for microservice or distributed system.
- gRPC connection
- Wrapped by grpc protocol (fast and high performance RPC framework) for requesting configuration to config server.
- Hystrix
- will implement later
- In-Memory cache
- Avoid too many requests to config server
- HTTP connection
- will implement later.
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.sayurbox.config4live";
option java_outer_classname = "LiveConfigurationProto";
option objc_class_prefix = "HLW";
package config4live;
service LiveConfiguration {
// Find config by name
rpc FindConfig (ConfigRequest) returns (ConfigResponse) {}
}
message ConfigRequest {
string name = 1;
}
message ConfigResponse {
string id = 1;
string name = 2;
string value = 3;
string description = 4;
enum Format {
text = 0;
number = 1;
bool = 2;
json = 3;
}
Format format = 5;
string owner = 6;
}
Add the JitPack repository to your root build file
--
Add the dependency
--
Create source (grpc url is required, hystrx config is optional) and provider instance
const url = 'localhost';
const port = '30106';
const client = new Client();
client
.withGrpcUrl(url)
.withGrpcPort(port)
.enableDebugMode()
.build()
// find configuration with default value
client.findConfig('nearest_distance_tolerance_km', 20).then((data) => {
console.log(data);
})