1.0.10 • Published 8 months ago

consul-balancer v1.0.10

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

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 instance
  • consulBalancer.getPassingServiceByRandom(serviceName): get the info of passing service by random
  • consulBalancer.register(options?: RegisterOptions): registers the discovery service
  • consulBalancer.deregister(serviceId?: string): deregister the discovery service
  • consulBalancer.rest(serviceName, pathName, urlOptions): async function load balance http utils
1.0.9

8 months ago

1.0.8

8 months ago

1.0.10

8 months ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago