Skip to content

Commit f282315

Browse files
author
aoife cassidy
authored
refactor(job): show job request attrs on print (#370)
1 parent 2b0a1e3 commit f282315

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

.changeset/tall-apes-hug.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@livekit/agents": patch
3+
---
4+
5+
refactor(job): show job request attrs on print

agents/src/job.ts

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -255,46 +255,35 @@ export class JobProcess {
255255
* requests should fill idle processes and which should be outright rejected.
256256
*/
257257
export class JobRequest {
258-
#job: proto.Job;
259258
#onReject: () => Promise<void>;
260259
#onAccept: (args: JobAcceptArguments) => Promise<void>;
261260

261+
/** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */
262+
readonly job: proto.Job;
263+
/** @returns The ID of the job, set by the LiveKit server */
264+
readonly id: string;
265+
/** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */
266+
readonly room?: proto.Room;
267+
/** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */
268+
readonly publisher?: proto.ParticipantInfo;
269+
/** @returns The agent's name, as set in {@link WorkerOptions} */
270+
readonly agentName: string;
271+
262272
/** @internal */
263273
constructor(
264274
job: proto.Job,
265275
onReject: () => Promise<void>,
266276
onAccept: (args: JobAcceptArguments) => Promise<void>,
267277
) {
268-
this.#job = job;
278+
this.job = job;
279+
this.id = job.id;
280+
this.room = job.room;
281+
this.publisher = job.participant;
282+
this.agentName = job.agentName;
269283
this.#onReject = onReject;
270284
this.#onAccept = onAccept;
271285
}
272286

273-
/** @returns The ID of the job, set by the LiveKit server */
274-
get id(): string {
275-
return this.#job.id;
276-
}
277-
278-
/** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */
279-
get job(): proto.Job {
280-
return this.#job;
281-
}
282-
283-
/** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */
284-
get room(): proto.Room | undefined {
285-
return this.#job.room;
286-
}
287-
288-
/** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */
289-
get publisher(): proto.ParticipantInfo | undefined {
290-
return this.#job.participant;
291-
}
292-
293-
/** @returns The agent's name, as set in {@link WorkerOptions} */
294-
get agentName(): string {
295-
return this.#job.agentName;
296-
}
297-
298287
/** Rejects the job. */
299288
async reject() {
300289
await this.#onReject();

0 commit comments

Comments
 (0)