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

@discue/mongodb-resource-client

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@discue/mongodb-resource-client - npm Package Compare versions

Comparing version 0.23.0 to 0.24.0

4

lib/history.js

@@ -96,6 +96,6 @@ const { createTracer } = require('@discue/open-telemetry-tracing')

*/
async _eventHandler(action, { error, after, resourceIds }) {
async _eventHandler(action, { error, after, resourceIds, collectionName }) {
if (!error) {
return withActiveSpan(`${name}#handle-history-relevant-event`, { action, resourceIds }, async () => {
if (action === 'create') {
if (action === 'create' && collectionName != this._collectionName) {
await this._resourceStorage.create(resourceIds, {

@@ -102,0 +102,0 @@ history: [{

@@ -49,2 +49,3 @@ export = exports;

* @param {Array.<string>} ids the resource ids
* @param {any} span
* @param {Function} callback callback to execute with lock

@@ -63,2 +64,3 @@ * @param {Object} options

* @param {Array.<string>} ids the resource ids
* @param {any} span
* @param {Object} options

@@ -65,0 +67,0 @@ * @param {Number} [options.waitTimeout] max time to wait in milliseconds

const { createTracer } = require('@discue/open-telemetry-tracing')
const SpanStatusCode = require('@discue/open-telemetry-tracing/status-codes')
const ResourceStorage = require('./simple-resource-storage.js')
const { trace, SpanStatusCode } = require('@opentelemetry/api')
const { name } = require('../package.json')

@@ -99,3 +99,3 @@

async doWhileLocked(resourceIds, callback, { lockTimeout = 5_000, waitTimeout = 5_000, retryInterval = 125 } = {}) {
return withActiveSpan(`${name}#do-while-resource-locked`, { resourceIds, lockTimeout, waitTimeout, retryInterval }, async () => {
return withActiveSpan(`${name}#do-while-resource-locked`, { resourceIds, lockTimeout, waitTimeout, retryInterval }, async (span) => {
return new Promise((resolve, reject) => {

@@ -106,3 +106,3 @@ let timeout

// after the lock was established
this._doWhileLocked(resourceIds, async () => {
this._doWhileLocked(resourceIds, span, async () => {

@@ -112,3 +112,2 @@ timeout = setTimeout(() => {

.finally(() => {
const span = trace.getActiveSpan()
span.addEvent('Timeout waiting for lock')

@@ -128,3 +127,2 @@

}, (error) => {
const span = trace.getActiveSpan()
span.addEvent('Unable to aquire lock')

@@ -146,2 +144,3 @@ .setStatus(SpanStatusCode.ERROR)

* @param {Array.<string>} ids the resource ids
* @param {any} span
* @param {Function} callback callback to execute with lock

@@ -153,4 +152,4 @@ * @param {Object} options

*/
async _doWhileLocked(ids, callback, { waitTimeout = 5_000, retryInterval = 125 } = {}) {
const locked = await this._ensureIsLocked(ids, { waitTimeout, retryInterval })
async _doWhileLocked(ids, span, callback, { waitTimeout = 5_000, retryInterval = 125 } = {}) {
const locked = await this._ensureIsLocked(ids, span, { waitTimeout, retryInterval })
if (!locked) {

@@ -174,2 +173,3 @@ throw new Error('Unable to establish lock.')

* @param {Array.<string>} ids the resource ids
* @param {any} span
* @param {Object} options

@@ -180,3 +180,3 @@ * @param {Number} [options.waitTimeout] max time to wait in milliseconds

*/
async _ensureIsLocked(ids, { waitTimeout, retryInterval }) {
async _ensureIsLocked(ids, span, { waitTimeout, retryInterval }) {
const start = Date.now()

@@ -189,3 +189,2 @@

} catch (e) {
const span = trace.getActiveSpan()
span.addEvent('Document still locked', {

@@ -192,0 +191,0 @@ waitedFor: Date.now() - start,

@@ -7,3 +7,3 @@ const Base = require('./simple-resource-storage.js')

const { name } = require('../package.json')
const { SpanStatusCode } = require('@opentelemetry/api')
const SpanStatusCode = require('@discue/open-telemetry-tracing/status-codes')

@@ -10,0 +10,0 @@ /**

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.23.0",
"version": "0.24.0",
"description": "Simple wrapper around mongodb client allowing easier managing of resources",

@@ -54,3 +54,3 @@ "main": "lib/index",

"devDependencies": {
"@discue/open-telemetry-tracing": "^0.6.0",
"@discue/open-telemetry-tracing": "^0.8.0",
"@types/chai": "^4.3.11",

@@ -63,4 +63,4 @@ "@types/mocha": "^10.0.6",

"mocha": "^10.2.0",
"mongodb": "^6.3.0",
"mongodb-memory-server": "^9.1.3",
"mongodb": "^6.3.0",
"nodemon": "^3.0.2",

@@ -67,0 +67,0 @@ "standard-version": "^9.5.0",

@@ -25,3 +25,18 @@

## Components
**Please read the installation instructions mentioned below.**
## Installation
This module has built-in support for tracing via Open Telemetry. The necessary dependencies are not declared in the module's `package.json` to allow applications to enable or disable the tracing feature.
### Install with support for tracing
```bash
npm i @discue/mongodb-resource-client @discue/open-telemetry-tracing
```
### Install without tracing features
```bash
npm i @discue/mongodb-resource-client @discue/open-telemetry-tracing@npm:@discue/open-telemetry-tracing-noop
```
## Component References
- [Aggregations](README_AGGREGATIONS.md)

@@ -72,7 +87,7 @@ - [EventEmitter](README_EVENT_EMITTER.md)

## Installation
```bash
npm install @discue/mongodb-resource-client
```
## Tracing
This module has built-in support for tracing via Open Telemetry. Under the hood it uses [@discue/open-telemetry-tracing](https://github.com/discue/open-telemetry-tracing/).
Please read the installation instructions mentioned above.
## Run tests

@@ -79,0 +94,0 @@

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