Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

sayurbox/config4live-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ARCHIVED - moved to internal monorepo

Build Status

Config4live-nodejs

Centralized live configuration library for Nodejs. for microservice or distributed system.

Features

  • 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.

gRPC proto file format

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;
}

Usage

Add the JitPack repository to your root build file

--

Add the dependency

--

Example

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);
})

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published