Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@logzio-node-toolbox/consul

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@logzio-node-toolbox/consul - npm Package Compare versions

Comparing version 0.0.14 to 0.0.15

27

dist/index.d.ts

@@ -37,3 +37,3 @@ interface AnyObject {

onError?: VoidFunction;
watchOptions?: WatchOptionsInner;
options?: WatchOptionsInner;
}

@@ -56,3 +56,3 @@

registerData: RegisterData;
registerRetryOptions?: RegisterRetryOptions;
options?: RegisterRetryOptions;
}

@@ -64,13 +64,18 @@

}
export interface WatchAllOptions {
onChange?: VoidFunction;
onError?: VoidFunction;
options?: WatchOptionsInner;
}
export declare class Consul {
public constructor(consulOptions: ConsulOptions);
public validateConnected(validateOptions: ValidateOptions): void;
public constructor(options: ConsulOptions);
public validateConnected(options: ValidateOptions): void;
private buildKey(key: string): { key: string; value: AnyObject };
public get(key?: string): AnyObject;
public set(keyValueOptions: KeyValueOptions): void;
public set(options: KeyValueOptions): void;
public keys(key?: string): AnyObject;
public merge(keyValueOptions: KeyValueOptions): AnyObject;
public watch(watchOptions?: WatchOptions): void;
public register(registerOptions: RegisterOptions): void;
public registerInterval(registerIntervalOptions: RegisterIntervalOptions): void;
public merge(options: KeyValueOptions): AnyObject;
public watch(options?: WatchOptions): void;
public register(options: RegisterOptions): void;
public registerInterval(options: RegisterIntervalOptions): void;
public close(): void;

@@ -82,3 +87,3 @@ }

export declare class MultiConsul extends Consul {
public constructor(multiConsulOptions: MultiConsulOptions);
public constructor(options: MultiConsulOptions);
private _mergeAll(): AnyObject;

@@ -88,3 +93,3 @@ private _onOneChange(Values: { key: string; value: AnyObject }): AnyObject;

public getAll(): AnyObject;
public watchAll(onChange: VoidFunction): AnyObject;
public watchAll(options: WatchAllOptions): AnyObject;
}

@@ -79,3 +79,3 @@ import retry from 'async-retry';

async validateConnected(validateOptions = {}) {
async validateConnected(options = {}) {
let {

@@ -88,3 +88,3 @@ fail,

} = { ...this.validateOptions,
...validateOptions
...options
};

@@ -139,6 +139,6 @@

onError,
watchOptions = {}
options = {}
} = {}) {
if (!key || !onChange) return;
const options = {
const watchOptions = {
method: this.consulInstance.kv.get,

@@ -149,7 +149,10 @@ options: {

...this.watchOptions,
...watchOptions
...options
};
const watcher = this.consulInstance.watch(options);
const watcher = this.consulInstance.watch(watchOptions);
watcher.on('change', data => data && onChange(parseValue(data)));
watcher.on('error', err => err && onError(err, key));
watcher.on('error', error => error && onError({
error,
key
}));
this.openWatchersToClose.push(watcher);

@@ -160,10 +163,10 @@ }

data,
retryOptions
options
} = {}) {
if (!data.name || !data.id) throw new Error('must provide name and id to register for consul service discovery');
if (this.registerParams.id) return;
const options = { ...this.registerRetryOptions,
...retryOptions
const retryOptions = { ...this.registerRetryOptions,
...options
};
const list = await retry(async () => this.consulInstance.agent.service.list(), options);
const list = await retry(async () => this.consulInstance.agent.service.list(), retryOptions);
const isRegistered = Object.entries(list).some(([id, {

@@ -174,3 +177,3 @@ Service

if (!isRegistered) {
await retry(async () => this.consulInstance.agent.service.register(data), options);
await retry(async () => this.consulInstance.agent.service.register(data), retryOptions);
this.registerParams.id = data.id;

@@ -184,5 +187,5 @@ }

onError,
retryOptions
options
}) {
const options = { ...this.registerRetryOptions,
const retryOptions = { ...this.registerRetryOptions,
...retryOptions

@@ -195,3 +198,3 @@ };

data,
retryOptions: options
options
});

@@ -208,9 +211,9 @@ } catch (err) {

async close(registerRetryOptions = {}) {
async close(options = {}) {
if (this.registerParams.id) {
if (this.registerParams.timeoutId) clearTimeout(this.registerParams.timeoutId);
const options = { ...this.registerRetryOptions,
...registerRetryOptions
const registerRetryOptions = { ...this.registerRetryOptions,
...options
};
await retry(async () => this.consulInstance.agent.service.deregister(this.registerParams.id), options);
await retry(async () => this.consulInstance.agent.service.deregister(this.registerParams.id), registerRetryOptions);
}

@@ -449,3 +452,3 @@

})('versions', []).push({
version: '3.8.2',
version: '3.8.3',
mode: 'global',

@@ -1183,5 +1186,7 @@ copyright: '© 2021 Denis Pushkarev (zloirock.ru)'

onChange,
onError
onError,
options
}) {
_classPrivateFieldGet(this, _paths).forEach(path => this.watch({
options,
key: path,

@@ -1188,0 +1193,0 @@ onError,

{
"name": "@logzio-node-toolbox/consul",
"version": "0.0.14",
"version": "0.0.15",
"description": "Consul easy use for json configs and service discovery",

@@ -5,0 +5,0 @@ "main": "dist/index.cjs",

@@ -58,3 +58,3 @@ <p align="center">

### watch - listen to key change and invoke handler
receive same watchOptions object as the initializer ( will merge them together)
options - same watchOptions object as the initializer ( will merge them together)
```javascript

@@ -70,3 +70,3 @@ await consul.watch({

},
watchOptions
options
})

@@ -76,3 +76,3 @@ ```

### register - will register service to consul
receive same registerRetryOptions object as the initializer ( will merge them together)
options - same as registerRetryOptions object as the initializer ( will merge them together)
```javascript

@@ -90,3 +90,3 @@ interface RegisterData {

data,
registerRetryOptions
options
})

@@ -96,3 +96,3 @@ ```

### registerInterval - will create interval to validate service always register to consul
receive same registerRetryOptions object as the initializer ( will merge them together)
options - same as registerRetryOptions object as the initializer ( will merge them together)
```javascript

@@ -114,3 +114,3 @@ interface RegisterData {

},
registerRetryOptions
options
})

@@ -121,5 +121,5 @@ ```

#### close - deregister and close all watchers
receive same registerRetryOptions object as the initializer ( will merge them together)
options - same as registerRetryOptions object as the initializer ( will merge them together)
```javascript
await consul.close(registerRetryOptions)
await consul.close(options)
```

@@ -126,0 +126,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc