curved-optician-70497
02/27/2025, 7:38 AMgray-monkey-83525
02/27/2025, 7:38 AMWorkerOptions
class to define the behavior of each worker. Each worker can be configured to handle specific job requests based on criteria such as room metadata. Here's a basic outline:
1. Define Worker Options: Use WorkerOptions
to specify the entry point function, request function, and any prewarm functions. The request function can be used to accept or reject jobs based on custom logic.
2. Run Multiple Workers: You can run multiple instances of workers, each listening on different ports or with different configurations. This can be done by running separate processes for each worker.
3. Handle Job Requests: In the request function, use logic to determine whether a worker should accept a job based on the job's metadata or other criteria.
Here's a simplified example in Python:
from livekit.agents import WorkerOptions, cli
async def request_function(job_request):
if job_request.room.metadata == "desired_metadata":
await job_request.accept()
else:
await job_request.reject()
async def entrypoint(ctx):
# Your entrypoint logic here
if __name__ == "__main__":
workOps = WorkerOptions(request_fnc=request_function, entrypoint_fnc=entrypoint)
cli.run_app(workOps)
This setup allows you to run multiple workers, each capable of handling different job requests based on the logic defined in the request function.
Would you like more detailed guidance on any specific part of this setup?
Sources:
- https://livekit-users.slack.com/archives/C07FY8WHGPM/p1732564590.153089
- https://livekit-users.slack.com/archives/C07FY8WHGPM/p1732860048.913659 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.curved-optician-70497
02/28/2025, 6:20 AMgray-monkey-83525
02/28/2025, 6:20 AMcurved-optician-70497
03/10/2025, 12:30 PMtall-airline-16756
03/10/2025, 12:30 PMtall-airline-16756
03/10/2025, 12:30 PM