Skip to content

Commit d25d459

Browse files
Copilottorosent
andcommitted
Refactor: Use populateTagsMap helper for tag population in client.ts
Co-authored-by: torosent <17064840+torosent@users.noreply.github.com>
1 parent 31011e0 commit d25d459

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

packages/durabletask-js/src/client/client.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { FailureDetails } from "../task/failure-details";
2424
import { Logger, ConsoleLogger } from "../types/logger.type";
2525
import { StartOrchestrationOptions } from "../task/options";
2626
import { mapToRecord } from "../utils/tags.util";
27+
import { populateTagsMap } from "../utils/pb-helper.util";
2728

2829
// Re-export MetadataGenerator for backward compatibility
2930
export { MetadataGenerator } from "../utils/grpc-helper.util";
@@ -188,12 +189,7 @@ export class TaskHubGrpcClient {
188189
req.setInput(i);
189190
req.setScheduledstarttimestamp(ts);
190191

191-
if (tags) {
192-
const tagsMap = req.getTagsMap();
193-
for (const [key, value] of Object.entries(tags)) {
194-
tagsMap.set(key, value);
195-
}
196-
}
192+
populateTagsMap(req.getTagsMap(), tags);
197193

198194
this._logger.info(`Starting new ${name} instance with ID = ${req.getInstanceid()}`);
199195

packages/durabletask-js/src/utils/pb-helper.util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export function getStringValue(val?: string): StringValue | undefined {
254254
* to store tag key-value pairs.
255255
* @param tags - An optional record of tag key-value pairs to add to the map.
256256
*/
257-
function populateTagsMap(
257+
export function populateTagsMap(
258258
tagsMap: { set: (key: string, value: string) => void },
259259
tags?: Record<string, string>,
260260
): void {

0 commit comments

Comments
 (0)