Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qiwi/consul-service-discovery
Consul service discovery helper
https://github.com/qiwi/consul-service-discovery
js-platform
Last synced: 4 days ago
JSON representation
Consul service discovery helper
- Host: GitHub
- URL: https://github.com/qiwi/consul-service-discovery
- Owner: qiwi
- License: mit
- Created: 2018-10-09T13:08:37.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-22T01:32:41.000Z (5 months ago)
- Last Synced: 2024-07-16T14:21:12.848Z (4 months ago)
- Topics: js-platform
- Language: TypeScript
- Homepage:
- Size: 1.09 MB
- Stars: 6
- Watchers: 12
- Forks: 1
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Consul service discovery
[![CI](https://github.com/qiwi/consul-service-discovery/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/qiwi/consul-service-discovery/actions/workflows/ci.yaml)
[![npm (tag)](https://img.shields.io/npm/v/@qiwi/consul-service-discovery/latest.svg)](https://www.npmjs.com/package/@qiwi/consul-service-discovery)
[![Maintainability](https://api.codeclimate.com/v1/badges/585c9532e7570ecb9c95/maintainability)](https://codeclimate.com/github/qiwi/consul-service-discovery/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/585c9532e7570ecb9c95/test_coverage)](https://codeclimate.com/github/qiwi/consul-service-discovery/test_coverage)
[![CodeStyle](https://img.shields.io/badge/code%20style-lint--config--qiwi-brightgreen.svg)](https://github.com/qiwi/lint-config-qiwi)Consul service discovery helper.
## Install
```bash
npm i @qiwi/consul-service-discovery
yarn add @qiwi/consul-service-discovery
```## Usage
```javascript
import ConsulServiceDiscovery from '@qiwi/consul-service-discovery'const discovery = new ConsulServiceDiscovery({
host: '0.0.0.0', // local consul client host
port: 8000 // and port
})
const targetServiceName = 'example-api' // registered service
const serviceConnectionParams = await discovery.getConnectionParams(targetServiceName)console.log(serviceConnectionParams) // { host: example-api-1234.qiwi.com, post: 8000 }
```## Configure
You may override some inner lib deps like logger (console by default) or Promise implementations:
```javascript
ConsulServiceDiscovery.configure({
Promise, // Bluebird
logger, // log4js
Consul // consul client factory
})
```## License
[MIT](./LICENSE)