Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@hapiness/consul
Advanced tools
Readme
Consul
module for the Hapiness framework.
To get started with consul, you can begin with having a look at the consul official documentation
Consul
inside your hapiness application
yarn
or npm
it in your package.json
$ npm install --save @hapiness/core @hapiness/consul rxjs
or
$ yarn add @hapiness/core @hapiness/consul rxjs
"dependencies": {
"@hapiness/consul": "^1.0.0",
"@hapiness/core": "^1.5.1",
"rxjs": "^5.5.7",
//...
}
//...
Consul
inside your hapiness applicationYou need to include ConsulModule
in the imports
section of your module definition.
@HapinessModule(
{
version: '1.0.0',
declarations: [/* your declarations */],
providers: [/* your providers */],
exports: [/* your exports */],
imports: [ConsulModule /* other modules */]
}
)
export class MyModule { /* ... */ }
You need to inject the extension in bootstrap using setConfig to instantiate the module.
The config properties allowed for the extensions are defined like this:
export interface HapinessConsulClientOptions {
scheme?: string;
host?: string;
port?: string;
defaults?: {
consistent?: boolean;
dc?: string;
stale?: boolean;
token?: string;
wait?: string;
wan?: boolean;
ctx?: NodeJS.EventEmitter;
timeout?: number;
};
ca?: string;
baseUrl?: string;
}
Then just do like this:
Hapiness
.bootstrap(
MyModule,
[
ConsulExt.setConfig({
/* Put your config here */
})
])
.catch(err => done(err));
This library is in fact a wrapper of the famous consul node library but wrap all its functions to returns rxjs Observable
You can see the doc by clicking here
We provide a wrapper called ConsulService
exposing a client
getter that will allow you to access the consul client.
class FooProvider {
constructor(private _consul: ConsulService) {}
bar(): Observable<string> {
// Getting a key from the KV client of consul
return this._consul.client.kv.get('hello');
}
acquireLock(): void {
// Create a consul lock
const lock = this._consul.client.lock({ key: 'test' });
// Listen to lock events
lock.on('acquire', () => {
console.log('lock acquired'));
lock.release();
});
lock.on('release', () => console.log('lock released'));
lock.on('error', () => console.log('lock error:', err));
lock.on('end', (err) => console.log('lock released or there was a permanent failure'));
// Acquire the lock
lock.acquire();
}
}
To set up your development environment:
cd
to the main folder,npm or yarn install
,npm or yarn run test
.
./coverage/lcov-report/index.html
.Julien Fauville | Antoine Gomez | Sébastien Ritz | Nicolas Jessel |
Copyright (c) 2018 Hapiness Licensed under the MIT license.
FAQs
Hapiness module for consul
The npm package @hapiness/consul receives a total of 11 weekly downloads. As such, @hapiness/consul popularity was classified as not popular.
We found that @hapiness/consul demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.