sam-goodwin / eventual

Build scalable and durable micro-services with APIs, Messaging and Workflows
https://docs.eventual.ai
MIT License
174 stars 4 forks source link

Creating a Command with a duplicate name doesn't error until AWS CDK synt #362

Closed sam-goodwin closed 1 year ago

sam-goodwin commented 1 year ago

I recently ran into a problem where I gave two commands the same name. Problem was I didn't find out until i got an obscure error during CDK synth and a construct name duplicate error was thrown. This is not friendly for developers. We should fix.

Looks like we have some inconsistency with how we handle registrations. Some use maps, others don't. The ones that use maps validate that the name is unique, others don't.

export const commands = (globalThis._eventual.commands ??= []);

export const workflows = (): Map<string, Workflow> =>
  (globalThis._eventual.workflows ??= new Map<string, Workflow>());

export const transactions = (): Map<string, Transaction> =>
  (globalThis._eventual.transactions ??= new Map<string, Transaction>());