@studyportals/sp-r2d2
Version:
A framework that contains various components used when developing projects that will be deployed via AWS λ.
44 lines • 1.8 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.FirehoseAdapter = void 0;
const client_firehose_1 = require("@aws-sdk/client-firehose");
class FirehoseAdapter {
get client() {
if (!this._client) {
this._client = new client_firehose_1.FirehoseClient({ region: this.region });
}
return this._client;
}
constructor(streamName, region) {
this.streamName = streamName;
this.region = region;
}
stream(record) {
return __awaiter(this, void 0, void 0, function* () {
var parameters = {
DeliveryStreamName: this.streamName,
Record: {
Data: Buffer.from(record),
},
};
try {
const command = new client_firehose_1.PutRecordCommand(parameters);
yield this.client.send(command);
}
catch (error) {
throw Error(error);
}
});
}
}
exports.FirehoseAdapter = FirehoseAdapter;
//# sourceMappingURL=firehose-adapter.class.js.map