egg-etcd

0.0.5 • Public • Published

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

Package Sidebar

Install

npm i egg-etcd

Weekly Downloads

2

Version

0.0.5

License

MIT

Unpacked Size

6.73 kB

Total Files

5

Last publish

Collaborators

  • royneedyou