MCPcopy
hub / github.com/livekit/livekit / NewAgentClient

Function NewAgentClient

pkg/agent/client.go:93–130  ·  view source on GitHub ↗
(bus psrpc.MessageBus, config Config)

Source from the content-addressed store, hash-verified

91}
92
93func NewAgentClient(bus psrpc.MessageBus, config Config) (Client, error) {
94 client, err := rpc.NewAgentInternalClient(bus)
95 if err != nil {
96 return nil, err
97 }
98
99 c := &agentClient{
100 client: client,
101 config: config,
102 workers: workerpool.New(50),
103 subDone: make(chan struct{}),
104 }
105
106 sub, err := c.client.SubscribeWorkerRegistered(context.Background(), DefaultHandlerNamespace)
107 if err != nil {
108 return nil, err
109 }
110
111 c.invalidateSub = sub
112
113 go func() {
114 // invalidate cache
115 for range sub.Channel() {
116 c.mu.Lock()
117 c.roomNamespaces = nil
118 c.publisherNamespaces = nil
119 c.participantNamespaces = nil
120 c.roomAgentNames = nil
121 c.publisherAgentNames = nil
122 c.participantAgentNames = nil
123 c.mu.Unlock()
124 }
125
126 c.subDone <- struct{}{}
127 }()
128
129 return c, nil
130}
131
132func (c *agentClient) LaunchJob(ctx context.Context, desc *JobRequest) *serverutils.IncrementalDispatcher[*livekit.Job] {
133 var wg sync.WaitGroup

Callers 1

InitializeServerFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected