Introduce in-memory transactions for sessions

This commit is contained in:
Fedor Indutny 2021-05-17 11:03:42 -07:00 committed by Scott Nonnenberg
parent 403b3c5fc6
commit 94d2c56ab9
12 changed files with 874 additions and 391 deletions

View file

@ -142,6 +142,7 @@ const dataInterface: ClientInterface = {
createOrUpdateSession,
createOrUpdateSessions,
commitSessionsAndUnprocessed,
getSessionById,
getSessionsById,
bulkAddSessions,
@ -767,6 +768,12 @@ async function createOrUpdateSession(data: SessionType) {
async function createOrUpdateSessions(array: Array<SessionType>) {
await channels.createOrUpdateSessions(array);
}
async function commitSessionsAndUnprocessed(options: {
sessions: Array<SessionType>;
unprocessed: Array<UnprocessedType>;
}) {
await channels.commitSessionsAndUnprocessed(options);
}
async function getSessionById(id: string) {
const session = await channels.getSessionById(id);
@ -1353,22 +1360,14 @@ async function getUnprocessedById(id: string) {
return channels.getUnprocessedById(id);
}
async function saveUnprocessed(
data: UnprocessedType,
{ forceSave }: { forceSave?: boolean } = {}
) {
const id = await channels.saveUnprocessed(_cleanData(data), { forceSave });
async function saveUnprocessed(data: UnprocessedType) {
const id = await channels.saveUnprocessed(_cleanData(data));
return id;
}
async function saveUnprocesseds(
arrayOfUnprocessed: Array<UnprocessedType>,
{ forceSave }: { forceSave?: boolean } = {}
) {
await channels.saveUnprocesseds(_cleanData(arrayOfUnprocessed), {
forceSave,
});
async function saveUnprocesseds(arrayOfUnprocessed: Array<UnprocessedType>) {
await channels.saveUnprocesseds(_cleanData(arrayOfUnprocessed));
}
async function updateUnprocessedAttempts(id: string, attempts: number) {