Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change coordinator IDs to ISO8601 format #292

Merged
merged 3 commits into from
May 13, 2024
Merged

Conversation

Siegrift
Copy link
Collaborator

@Siegrift Siegrift commented May 2, 2024

Closes #280

Rationale

This should make the IDs easy to differentiate from each other, while being "unique enough". I don't see a huge need for UUIDs.

@Siegrift Siegrift requested a review from bdrhn9 May 2, 2024 12:53
@Siegrift Siegrift self-assigned this May 2, 2024
@@ -56,7 +56,7 @@ export const callSignedApi = async (url: string, timeout: number): Promise<Signe
};

export const runDataFetcher = async () => {
return logger.runWithContext({ dataFetcherCoordinatorId: Date.now().toString() }, async () => {
return logger.runWithContext({ dataFetcherCoordinatorId: new Date().toISOString() }, async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we continue with time, I'd prefer timestamp rather than ISO string cuz it's easier to search logs with timestamp. When you double-click on timestamp it will select all, it's not possible with ISO format 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D UUID would have the same issue though.

Anyway, let's close this and stick with timestamp.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The objective of switching to uuid is not about the double-click, it guarantees that the uniqueness. And it doesn't have to be uuid it can be 32-bit hex generated via node:crypto library.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but the JS timestamp is in MS so that's very low probability that the loops start at the same time. Anyway, 32-bit hex from node:crypto + a timestamp logged at the start of the coordinator seems like a trade-off that everyone is going to be happy with. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it looks like sweet-spot.

@Siegrift Siegrift closed this May 8, 2024
@Siegrift Siegrift reopened this May 8, 2024
Base automatically changed from verify-using-worker to main May 13, 2024 07:45
@@ -83,7 +83,7 @@ export const runDataFetcher = async () => {

const urlCount = urls.length;
const staggerTimeMs = signedDataFetchIntervalMs / urlCount;
logger.info('Fetching signed data.', { urlCount, staggerTimeMs });
logger.info('Fetching signed data.', { urlCount, staggerTimeMs, currentTime: new Date().toISOString() });
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message is logged as a basically the first thing, so I've logged the current time here instead of logging another message.

@Siegrift Siegrift merged commit 1574b73 into main May 13, 2024
4 checks passed
@Siegrift Siegrift deleted the change-coordinator-ids branch May 13, 2024 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use uuid as coordinator ID
2 participants