Skip to content

Commit

Permalink
chore: added timers for certain IMAP handlers (will remove in future)
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Jul 1, 2024
1 parent e020d82 commit 73e7582
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions helpers/imap/on-append.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ async function onAppend(path, flags, date, raw, session, fn) {
throw new IMAPError(
i18n.translate('IMAP_MESSAGE_SIZE_EXCEEDED', session.user.locale)
);

console.time(`append timer ${session.id}`);
const [bool, response] = await this.wsp.request({
action: 'append',
session: {
Expand All @@ -75,6 +77,7 @@ async function onAppend(path, flags, date, raw, session, fn) {
date,
raw
});
console.timeEnd(`append timer ${session.id}`);

fn(null, bool, response);
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions helpers/imap/on-copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async function onCopy(connection, mailboxId, update, session, fn) {
}, ms('15s'));
})();

console.time(`copy timer ${session.id}`);
const [bool, response] = await this.wsp.request({
action: 'copy',
session: {
Expand All @@ -57,6 +58,7 @@ async function onCopy(connection, mailboxId, update, session, fn) {
mailboxId,
update
});
console.timeEnd(`copy timer ${session.id}`);
clearTimeout(timeout);
fn(null, bool, response);
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions helpers/imap/on-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ async function onCreate(path, session, fn) {

if (this.wsp) {
try {
console.time(`create timer ${session.id}`);
const data = await this.wsp.request({
action: 'create',
session: {
Expand All @@ -35,6 +36,7 @@ async function onCreate(path, session, fn) {
},
path
});
console.timeEnd(`create timer ${session.id}`);
fn(null, ...data);
} catch (err) {
fn(err);
Expand Down
2 changes: 2 additions & 0 deletions helpers/imap/on-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async function onDelete(path, session, fn) {

if (this.wsp) {
try {
console.time(`delete timer ${session.id}`);
const [bool, mailboxId] = await this.wsp.request({
action: 'delete',
session: {
Expand All @@ -41,6 +42,7 @@ async function onDelete(path, session, fn) {
},
path
});
console.timeEnd(`delete timer ${session.id}`);

fn(null, bool, mailboxId);
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions helpers/imap/on-expunge.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async function onExpunge(mailboxId, update, session, fn) {

if (this.wsp) {
try {
console.time(`expunge timer ${session.id}`);
const [bool] = await this.wsp.request({
action: 'expunge',
session: {
Expand All @@ -46,6 +47,7 @@ async function onExpunge(mailboxId, update, session, fn) {
mailboxId,
update
});
console.timeEnd(`expunge timer ${session.id}`);

fn(null, bool);
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions helpers/imap/on-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async function onFetch(mailboxId, options, session, fn) {

if (this.wsp) {
try {
console.time(`fetch timer ${session.id}`);
const [bool, response] = await this.wsp.request({
action: 'fetch',
session: {
Expand All @@ -52,6 +53,7 @@ async function onFetch(mailboxId, options, session, fn) {
mailboxId,
options
});
console.timeEnd(`fetch timer ${session.id}`);

fn(null, bool, response);
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions helpers/imap/on-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async function onSearch(mailboxId, options, session, fn) {

if (this.wsp) {
try {
console.time(`search timer ${session.id}`);
const data = await this.wsp.request({
action: 'search',
session: {
Expand All @@ -43,6 +44,7 @@ async function onSearch(mailboxId, options, session, fn) {
mailboxId,
options
});
console.timeEnd(`search timer ${session.id}`);
fn(null, ...data);
} catch (err) {
fn(err);
Expand Down
2 changes: 2 additions & 0 deletions helpers/imap/on-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async function onStore(mailboxId, update, session, fn) {

if (this.wsp) {
try {
console.time(`store timer ${session.id}`);
const [bool, response] = await this.wsp.request({
action: 'store',
session: {
Expand All @@ -53,6 +54,7 @@ async function onStore(mailboxId, update, session, fn) {
mailboxId,
update
});
console.timeEnd(`store timer ${session.id}`);

fn(null, bool, response);
} catch (err) {
Expand Down

0 comments on commit 73e7582

Please sign in to comment.