Skip to content

Commit

Permalink
Use activities.{log,info}
Browse files Browse the repository at this point in the history
  • Loading branch information
dandavison committed Jul 12, 2024
1 parent 71eb3cb commit b1801b5
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions updates_and_signals/safe_message_handlers/src/activities.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as activities from '@temporalio/activity';

interface AssignNodesToJobInput {
nodes: string[];
jobName: string;
Expand All @@ -9,20 +11,16 @@ interface UnassignNodesForJobInput {
}

export async function startCluster(): Promise<void> {
console.log('Starting cluster');
await sleep(100); // Simulate RPC
activities.log.info('Starting cluster');
await activities.sleep(100); // Simulate RPC
}

export async function assignNodesToJob(input: AssignNodesToJobInput): Promise<void> {
console.log(`Assigning nodes ${input.nodes} to job ${input.jobName}`);
await sleep(100); // Simulate RPC
activities.log.info(`Assigning nodes ${input.nodes} to job ${input.jobName}`);
await activities.sleep(100); // Simulate RPC
}

export async function unassignNodesForJob(input: UnassignNodesForJobInput): Promise<void> {
console.log(`Unassigning nodes ${input.nodes} from job ${input.jobName}`);
await sleep(100); // Simulate RPC
}

async function sleep(ms: number): Promise<void> {
await new Promise((resolve) => setTimeout(resolve, ms));
activities.log.info(`Unassigning nodes ${input.nodes} from job ${input.jobName}`);
await activities.sleep(100); // Simulate RPC
}

0 comments on commit b1801b5

Please sign in to comment.