0.0.5 • Published 4 years ago

egg-etcd v0.0.5

Weekly downloads
29
License
MIT
Repository
github
Last release
4 years ago

egg-etcd

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-etcd --save

Usage

// {app_root}/config/plugin.js
exports.eggEtcd = {
  enable: true,
  package: 'egg-etcd',
};

Configuration

// {app_root}/config/config.default.js
exports.eggEtcd = {
  hosts: [
    'your-etcd-cluster1.host.com',
    'your-etcd-cluster2.host.com',
    'your-etcd-cluster3.host.com',
  ],
  auth: {
    username: 'your_user_name',
    password: 'your_password',
  },
};

see config/config.default.js for more detail.

Example

// app.js

// get value
app.etcd.get('foo').string().then(value => {
  console.log('foo value is:', value);
});

// watch value
app.etcd
      .watch()
      .key('bar')
      .create()
      .then(watcher => {
        watcher.on('put', res => {
          console.log('bar value is:', res.value);
        });
      });

More Info

This plugin is based on Etcd3, you can read Etcd3 document for more info.

Questions & Suggestions

Please open an issue here.

License

MIT

0.0.5

4 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago