@elastic.io/batching-library
Advanced tools
Comparing version 0.0.2 to 0.0.3-dev.1
import { AbstractStore } from './storage/IStore'; | ||
import { Batch, BatchConfig, BatchItem, BatchStatus } from './entity/dto' ; | ||
import { Batch, BatchConfig, BatchItem, BatchStatus } from './entity/dto'; | ||
import componentLogger from '@elastic.io/component-logger'; | ||
@@ -66,2 +66,11 @@ | ||
} | ||
/** | ||
* Atomic Delete Batch | ||
* @param batchId batch id | ||
* @return Number of deleted items. | ||
*/ | ||
public async deleteBatchById(batchId: string): Promise<number> { | ||
return await this.store.delete(batchId); | ||
} | ||
} |
@@ -24,3 +24,3 @@ import { AbstractStore } from './storage/IStore'; | ||
/** | ||
* Atomic Get 'READY' batches and locks them (set status tu 'LOCKED') | ||
* Atomic Get 'READY' batches and locks them (set status to 'LOCKED') | ||
*/ | ||
@@ -38,3 +38,3 @@ getReadyBatches(): Promise<Batch[]>; | ||
* Ensures that item can be added to batch. If cant add to existing create new batch. | ||
* Check batches after insett new item | ||
* Check batches after insert new item | ||
* @param item batch item | ||
@@ -44,3 +44,9 @@ * @return Batch with saved item. | ||
saveItem(item: BatchItem): Promise<Batch>; | ||
/** | ||
* Atomic Delete Batch | ||
* @param batchId batch id | ||
* @return Number of deleted items. | ||
*/ | ||
deleteBatchById(batchId: string): Promise<number>; | ||
} | ||
//# sourceMappingURL=client.d.ts.map |
@@ -38,3 +38,3 @@ "use strict"; | ||
/** | ||
* Atomic Get 'READY' batches and locks them (set status tu 'LOCKED') | ||
* Atomic Get 'READY' batches and locks them (set status to 'LOCKED') | ||
*/ | ||
@@ -59,3 +59,3 @@ async getReadyBatches() { | ||
* Ensures that item can be added to batch. If cant add to existing create new batch. | ||
* Check batches after insett new item | ||
* Check batches after insert new item | ||
* @param item batch item | ||
@@ -71,4 +71,12 @@ * @return Batch with saved item. | ||
} | ||
/** | ||
* Atomic Delete Batch | ||
* @param batchId batch id | ||
* @return Number of deleted items. | ||
*/ | ||
async deleteBatchById(batchId) { | ||
return await this.store.delete(batchId); | ||
} | ||
} | ||
exports.BatchClient = BatchClient; | ||
//# sourceMappingURL=client.js.map |
@@ -105,5 +105,5 @@ /// <reference types="node" /> | ||
/** | ||
* @async update batches status by batch Configuration. | ||
* @async update batches status by batch Configuration to READY. | ||
* | ||
* @param batchConfig of batch Configuration. | ||
* @param batchConfig batch Configuration. | ||
* @return number(count) of updated objects. | ||
@@ -110,0 +110,0 @@ */ |
{ | ||
"name": "@elastic.io/batching-library", | ||
"version": "0.0.2", | ||
"version": "0.0.3-dev.1", | ||
"description": "Library for batching implementation on elastic.io", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/elasticio/batching-library#readme", |
@@ -216,2 +216,33 @@ import { MongoStore } from '../../lib/storage/impl/MongoStore'; | ||
}); | ||
describe('delete Batch', () => { | ||
let mgStore; | ||
const options = Object.create(opt); | ||
options.dbName = 'deleteBatch'; | ||
before(async () => { | ||
mgStore = new MongoStore('deleteBatch', uri, options); | ||
if (dropDB) { | ||
const db = await mgStore.openConnection(); | ||
await db.useDb(options.dbName); | ||
await db.dropDatabase(); | ||
} | ||
}); | ||
it('should delete batch by id', async () => { | ||
const conf = new BatchConfig(72, 30, 1000); | ||
const client = new BatchClient(mgStore, conf); | ||
const items = [ | ||
{ num: { msg: 1 } }, | ||
{ num: { msg: 2 } }, | ||
]; | ||
const batch = await Promise.all(items.map(item => client.saveItem(new BatchItem(item.num.msg.toString(), item)))); | ||
const result = await client.deleteBatchById(batch[0].id); | ||
expect(result).to.be.equal(1); | ||
}); | ||
after(async () => { | ||
await mgStore.close(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
170961
49
3342
1