Skip to content

Commit f9e31cf

Browse files
authored
Replace object-storage-client with maester-client (#199)
* #6414 replace object-storage-client with maester-client * #6414 update version
1 parent 971e101 commit f9e31cf

File tree

4 files changed

+893
-87
lines changed

4 files changed

+893
-87
lines changed

lib/sailor.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const RestApiClient = require('elasticio-rest-node');
1010
const assert = require('assert');
1111
const co = require('co');
1212
const pThrottle = require('p-throttle');
13-
const { ObjectStorage } = require('@elastic.io/object-storage-client');
13+
const { ObjectStorage } = require('@elastic.io/maester-client');
1414
const { Readable } = require('stream');
1515

1616
const AMQP_HEADER_META_PREFIX = 'x-eio-meta-';
@@ -280,7 +280,7 @@ class Sailor {
280280
logger.info('Going to fetch message body.', { objectId });
281281

282282
try {
283-
object = await this.objectStorage.getAsJSON(
283+
object = await this.objectStorage.getOne(
284284
objectId,
285285
{ jwtPayloadOrToken: this.settings.OBJECT_STORAGE_TOKEN }
286286
);
@@ -297,7 +297,7 @@ class Sailor {
297297

298298
uploadMessageBody(bodyBuf) {
299299
const stream = () => Readable.from(bodyBuf);
300-
return this.objectStorage.addAsStream(
300+
return this.objectStorage.add(
301301
stream,
302302
{ jwtPayloadOrToken: this.settings.OBJECT_STORAGE_TOKEN }
303303
);

mocha_spec/unit/sailor.spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ describe('Sailor', () => {
10611061
let passthroughRequestStub;
10621062
let runExecSpy;
10631063
beforeEach(async () => {
1064-
const getObjectStub = sandbox.stub(sailor.objectStorage, 'getAsJSON');
1064+
const getObjectStub = sandbox.stub(sailor.objectStorage, 'getOne');
10651065
bodyRequestStub = getObjectStub
10661066
.withArgs(bodyObjectId, { jwtPayloadOrToken: settings.OBJECT_STORAGE_TOKEN })
10671067
.resolves(body);
@@ -1142,7 +1142,7 @@ describe('Sailor', () => {
11421142
let passthroughRequestStub;
11431143
let runExecSpy;
11441144
beforeEach(async () => {
1145-
const getObjectStub = sandbox.stub(sailor.objectStorage, 'getAsJSON');
1145+
const getObjectStub = sandbox.stub(sailor.objectStorage, 'getOne');
11461146
bodyRequestStub = getObjectStub
11471147
.withArgs(bodyObjectId, { jwtPayloadOrToken: settings.OBJECT_STORAGE_TOKEN })
11481148
.resolves(body);
@@ -1194,7 +1194,7 @@ describe('Sailor', () => {
11941194
runExecSpy = sandbox.spy(sailor, 'runExec');
11951195

11961196
passthroughRequestStub = sandbox
1197-
.stub(sailor.objectStorage, 'getAsJSON')
1197+
.stub(sailor.objectStorage, 'getOne')
11981198
.withArgs(passthroughObjectId, { jwtPayloadOrToken: settings.OBJECT_STORAGE_TOKEN })
11991199
.resolves(passThroughBody);
12001200

@@ -1309,7 +1309,7 @@ describe('Sailor', () => {
13091309
});
13101310
});
13111311

1312-
sandbox.stub(sailor.objectStorage, 'getAsJSON')
1312+
sandbox.stub(sailor.objectStorage, 'getOne')
13131313
.withArgs(passthroughObjectId, { jwtPayloadOrToken: settings.OBJECT_STORAGE_TOKEN })
13141314
.resolves({ passthrough: 'body' });
13151315

@@ -1322,7 +1322,7 @@ describe('Sailor', () => {
13221322
let bodyObjectId;
13231323
beforeEach(async () => {
13241324
bodyObjectId = 'body-object-id';
1325-
addObjectStub = sandbox.stub(sailor.objectStorage, 'addAsStream').resolves(bodyObjectId);
1325+
addObjectStub = sandbox.stub(sailor.objectStorage, 'add').resolves(bodyObjectId);
13261326
});
13271327

13281328
it('should send lightweight', async () => {
@@ -1382,7 +1382,7 @@ describe('Sailor', () => {
13821382
describe('and objects can not be uploaded successfully', () => {
13831383
let addObjectStub;
13841384
beforeEach(async () => {
1385-
addObjectStub = sandbox.stub(sailor.objectStorage, 'addAsStream').rejects(new Error());
1385+
addObjectStub = sandbox.stub(sailor.objectStorage, 'add').rejects(new Error());
13861386
});
13871387

13881388
it('should not upload lightweight', async () => {
@@ -1416,7 +1416,7 @@ describe('Sailor', () => {
14161416
});
14171417
});
14181418

1419-
sandbox.stub(sailor.objectStorage, 'getAsJSON')
1419+
sandbox.stub(sailor.objectStorage, 'getOne')
14201420
.withArgs(passthroughObjectId, { jwtPayloadOrToken: settings.OBJECT_STORAGE_TOKEN })
14211421
.resolves({ passthrough: 'body' });
14221422

@@ -1427,7 +1427,7 @@ describe('Sailor', () => {
14271427
describe('and all objects can be uploaded successfully', () => {
14281428
let addObjectSpy;
14291429
beforeEach(async () => {
1430-
addObjectSpy = sandbox.spy(sailor.objectStorage, 'addAsStream');
1430+
addObjectSpy = sandbox.spy(sailor.objectStorage, 'add');
14311431
});
14321432

14331433
it('should not send lightweight', async () => {

0 commit comments

Comments
 (0)