Skip to content

Commit

Permalink
Replace object-storage-client with maester-client (#199)
Browse files Browse the repository at this point in the history
* #6414 replace object-storage-client with maester-client

* #6414 update version
  • Loading branch information
Allirey committed Oct 17, 2022
1 parent 971e101 commit f9e31cf
Show file tree
Hide file tree
Showing 4 changed files with 893 additions and 87 deletions.
6 changes: 3 additions & 3 deletions lib/sailor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const RestApiClient = require('elasticio-rest-node');
const assert = require('assert');
const co = require('co');
const pThrottle = require('p-throttle');
const { ObjectStorage } = require('@elastic.io/object-storage-client');
const { ObjectStorage } = require('@elastic.io/maester-client');
const { Readable } = require('stream');

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

try {
object = await this.objectStorage.getAsJSON(
object = await this.objectStorage.getOne(
objectId,
{ jwtPayloadOrToken: this.settings.OBJECT_STORAGE_TOKEN }
);
Expand All @@ -297,7 +297,7 @@ class Sailor {

uploadMessageBody(bodyBuf) {
const stream = () => Readable.from(bodyBuf);
return this.objectStorage.addAsStream(
return this.objectStorage.add(
stream,
{ jwtPayloadOrToken: this.settings.OBJECT_STORAGE_TOKEN }
);
Expand Down
16 changes: 8 additions & 8 deletions mocha_spec/unit/sailor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ describe('Sailor', () => {
let passthroughRequestStub;
let runExecSpy;
beforeEach(async () => {
const getObjectStub = sandbox.stub(sailor.objectStorage, 'getAsJSON');
const getObjectStub = sandbox.stub(sailor.objectStorage, 'getOne');
bodyRequestStub = getObjectStub
.withArgs(bodyObjectId, { jwtPayloadOrToken: settings.OBJECT_STORAGE_TOKEN })
.resolves(body);
Expand Down Expand Up @@ -1142,7 +1142,7 @@ describe('Sailor', () => {
let passthroughRequestStub;
let runExecSpy;
beforeEach(async () => {
const getObjectStub = sandbox.stub(sailor.objectStorage, 'getAsJSON');
const getObjectStub = sandbox.stub(sailor.objectStorage, 'getOne');
bodyRequestStub = getObjectStub
.withArgs(bodyObjectId, { jwtPayloadOrToken: settings.OBJECT_STORAGE_TOKEN })
.resolves(body);
Expand Down Expand Up @@ -1194,7 +1194,7 @@ describe('Sailor', () => {
runExecSpy = sandbox.spy(sailor, 'runExec');

passthroughRequestStub = sandbox
.stub(sailor.objectStorage, 'getAsJSON')
.stub(sailor.objectStorage, 'getOne')
.withArgs(passthroughObjectId, { jwtPayloadOrToken: settings.OBJECT_STORAGE_TOKEN })
.resolves(passThroughBody);

Expand Down Expand Up @@ -1309,7 +1309,7 @@ describe('Sailor', () => {
});
});

sandbox.stub(sailor.objectStorage, 'getAsJSON')
sandbox.stub(sailor.objectStorage, 'getOne')
.withArgs(passthroughObjectId, { jwtPayloadOrToken: settings.OBJECT_STORAGE_TOKEN })
.resolves({ passthrough: 'body' });

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

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

it('should not upload lightweight', async () => {
Expand Down Expand Up @@ -1416,7 +1416,7 @@ describe('Sailor', () => {
});
});

sandbox.stub(sailor.objectStorage, 'getAsJSON')
sandbox.stub(sailor.objectStorage, 'getOne')
.withArgs(passthroughObjectId, { jwtPayloadOrToken: settings.OBJECT_STORAGE_TOKEN })
.resolves({ passthrough: 'body' });

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

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

0 comments on commit f9e31cf

Please sign in to comment.