Skip to content

refactor(job): show job request attrs on print #370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tall-apes-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@livekit/agents": patch
---

refactor(job): show job request attrs on print
43 changes: 16 additions & 27 deletions agents/src/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,46 +255,35 @@ export class JobProcess {
* requests should fill idle processes and which should be outright rejected.
*/
export class JobRequest {
#job: proto.Job;
#onReject: () => Promise<void>;
#onAccept: (args: JobAcceptArguments) => Promise<void>;

/** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */
readonly job: proto.Job;
/** @returns The ID of the job, set by the LiveKit server */
readonly id: string;
/** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */
readonly room?: proto.Room;
/** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */
readonly publisher?: proto.ParticipantInfo;
/** @returns The agent's name, as set in {@link WorkerOptions} */
readonly agentName: string;

/** @internal */
constructor(
job: proto.Job,
onReject: () => Promise<void>,
onAccept: (args: JobAcceptArguments) => Promise<void>,
) {
this.#job = job;
this.job = job;
this.id = job.id;
this.room = job.room;
this.publisher = job.participant;
this.agentName = job.agentName;
this.#onReject = onReject;
this.#onAccept = onAccept;
}

/** @returns The ID of the job, set by the LiveKit server */
get id(): string {
return this.#job.id;
}

/** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */
get job(): proto.Job {
return this.#job;
}

/** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */
get room(): proto.Room | undefined {
return this.#job.room;
}

/** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */
get publisher(): proto.ParticipantInfo | undefined {
return this.#job.participant;
}

/** @returns The agent's name, as set in {@link WorkerOptions} */
get agentName(): string {
return this.#job.agentName;
}

/** Rejects the job. */
async reject() {
await this.#onReject();
Expand Down
Loading