Skip to content

Commit

Permalink
chore: improve messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
GPaoloni committed Nov 14, 2024
1 parent 8bd09a1 commit 020057d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
4 changes: 2 additions & 2 deletions hrm-domain/hrm-core/case/caseReindexService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ export const reindexCasesStream = async (
});

this.push(
`${new Date().toISOString()},${accountSid},contad id: ${
`${new Date().toISOString()}, ${accountSid}, case id: ${
caseObj.id
} Success, MessageId ${MessageId}
\n`,
);
} catch (err) {
this.push(
`${new Date().toISOString()},${accountSid},contad id: ${caseObj.id} Error: ${
`${new Date().toISOString()}, ${accountSid}, case id: ${caseObj.id} Error: ${
err.message?.replace('"', '""') || String(err)
}\n`,
);
Expand Down
8 changes: 4 additions & 4 deletions hrm-domain/hrm-core/contact/contactsReindexService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ export const reindexContactsStream = async (
});

this.push(
`${new Date().toISOString()},${accountSid},contad id: ${
`${new Date().toISOString()}, ${accountSid}, contact id: ${
contact.id
} Success, MessageId ${MessageId}
\n`,
);
} catch (err) {
this.push(
`${new Date().toISOString()},${accountSid},contad id: ${contact.id} Error: ${
err.message?.replace('"', '""') || String(err)
}\n`,
`${new Date().toISOString()}, ${accountSid}, contact id: ${
contact.id
} Error: ${err.message?.replace('"', '""') || String(err)}\n`,
);
}
callback();
Expand Down
15 changes: 3 additions & 12 deletions packages/elasticsearch-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,12 @@ export type PassThroughConfig<T> = {
client: EsClient;
};

const getConfigSsmParameterKey = (indexType: string) =>
`/${process.env.NODE_ENV}/${indexType}/${process.env.AWS_REGION}/elasticsearch_config`;

//TODO: type for config
const getEsConfig = async ({
config,
indexType,
ssmConfigParameter,
}: {
config: ClientOptions | undefined;
indexType: string;
config?: ClientOptions | undefined;
ssmConfigParameter?: string;
}) => {
console.log('config', config);
Expand All @@ -102,8 +97,7 @@ const getEsConfig = async ({
return JSON.parse(await getSsmParameter(ssmConfigParameter));
}

// TODO: remove this if it's not used anymore?
return JSON.parse(await getSsmParameter(getConfigSsmParameterKey(indexType)));
throw new Error(`getEsConfig error: no valid config provided to initialize client`);
};

/**
Expand All @@ -123,7 +117,6 @@ export type IndexClient<T> = {
const getClientOrMock = async ({
config,
index,
indexType,
ssmConfigParameter,
}: GetClientOrMockArgs) => {
// TODO: mock client for unit tests
Expand All @@ -132,9 +125,7 @@ const getClientOrMock = async ({
// return mock;
// }

const client = new EsClient(
await getEsConfig({ config, indexType, ssmConfigParameter }),
);
const client = new EsClient(await getEsConfig({ config, ssmConfigParameter }));
return {
client,
index,
Expand Down

0 comments on commit 020057d

Please sign in to comment.