@studyportals/sp-r2d2
Version:
A framework that contains various components used when developing projects that will be deployed via AWS λ.
49 lines • 2 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SQSAdapter = void 0;
const client_sqs_1 = require("@aws-sdk/client-sqs");
class SQSAdapter {
get queueUrl() {
return this._queueUrl;
}
get client() {
if (!this._client) {
this._client = new client_sqs_1.SQSClient();
}
return this._client;
}
constructor(queueUrl = '') {
this._queueUrl = queueUrl;
}
sendDataMessage(data) {
return __awaiter(this, void 0, void 0, function* () {
const command = new client_sqs_1.SendMessageCommand({
MessageBody: JSON.stringify(data),
QueueUrl: this.queueUrl,
});
yield this.client.send(command);
});
}
sendGroupedDataMessage(data, messageGroupId) {
return __awaiter(this, void 0, void 0, function* () {
const stringifiedData = JSON.stringify(data);
const command = new client_sqs_1.SendMessageCommand({
MessageBody: stringifiedData,
QueueUrl: this.queueUrl,
MessageGroupId: messageGroupId,
});
yield this.client.send(command);
});
}
}
exports.SQSAdapter = SQSAdapter;
//# sourceMappingURL=sqs-adapter.class.js.map