Skip to content

[Feature]: branch/iteration namer for concurrent operations #303

@yaythomas

Description

@yaythomas

What would you like?

Name an iteration of map:

const results = await context.map(
  "process-items",
  items,
  async (ctx, item, index) => {
    return await ctx.step(`process-${index}`, async () => process(item));
  },
  {
    maxConcurrency: 5,
    itemNamer: (item, index) => `item-${item.id}`, // Custom iteration names
  },
);

Name a branch of parallel:

const results = await context.parallel(
  "parallel-ops",
  [
    { 
      name: "fetch-user-data",  // Custom name for this branch
      func: async (ctx) => ctx.step(async () => fetchData1()) 
    },
    { 
      name: "fetch-order-history",  // Custom name for this branch
      func: async (ctx) => ctx.step(async () => fetchData2()) 
    },
  ],
  { maxConcurrency: 2 },
);
export interface NamedParallelBranch<TResult, Logger extends DurableLogger> {
  name?: string;
  func: ParallelFunc<TResult, Logger>;
}

Possible Implementation

No response

Is this a breaking change?

No

Does this require an RFC?

No

Additional Context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions