consul-balancer
v1.0.10
Published
consul service discovery and balancing
Downloads
7
Maintainers
Readme
consul-balancer
consul service discovery and balancing
usage
npm install consul-balancer
import { ConsulBalancer } from "consul-balancer"
const consulBalancer = new ConsulBalancer({
host: "x.x.x.x",
port: 8500,
secure: false,
discovery: {
enable: true,
register: true, // auto register discovery service
deregister: true, // auto register discovery service after process exited
serviceName: "consul-balancer",
servicePort: 8080,
healthCheckHTTP: "/healthy",
},
})
API
consulBalancer.getConsulInstance()
: get the consul client instanceconsulBalancer.getPassingServiceByRandom(serviceName)
: get the info of passing service by randomconsulBalancer.register(options?: RegisterOptions)
: registers the discovery serviceconsulBalancer.deregister(serviceId?: string)
: deregister the discovery serviceconsulBalancer.rest(serviceName, pathName, urlOptions)
: [async function] load balance http utils