MCPcopy Create free account
hub / github.com/daodst/chat / InputRoomEvents

Method InputRoomEvents

roomserver/internal/input/input.go:336–369  ·  view source on GitHub ↗

InputRoomEvents implements api.RoomserverInternalAPI

(
	ctx context.Context,
	request *api.InputRoomEventsRequest,
	response *api.InputRoomEventsResponse,
)

Source from the content-addressed store, hash-verified

334
335// InputRoomEvents implements api.RoomserverInternalAPI
336func (r *Inputer) InputRoomEvents(
337 ctx context.Context,
338 request *api.InputRoomEventsRequest,
339 response *api.InputRoomEventsResponse,
340) {
341 // Queue up the event into the roomserver.
342 replySub, err := r.queueInputRoomEvents(ctx, request)
343 if err != nil {
344 response.ErrMsg = err.Error()
345 return
346 }
347
348 // If we aren't waiting for synchronous responses then we can
349 // give up here, there is nothing further to do.
350 if replySub == nil {
351 return
352 }
353
354 // Otherwise, we'll want to sit and wait for the responses
355 // from the roomserver. There will be one response for every
356 // input we submitted. The last error value we receive will
357 // be the one returned as the error string.
358 defer replySub.Drain() // nolint:errcheck
359 for i := 0; i < len(request.InputRoomEvents); i++ {
360 msg, err := replySub.NextMsgWithContext(ctx)
361 if err != nil {
362 response.ErrMsg = err.Error()
363 return
364 }
365 if len(msg.Data) > 0 {
366 response.ErrMsg = string(msg.Data)
367 }
368 }
369}
370
371var roomserverInputBackpressure = prometheus.NewGaugeVec(
372 prometheus.GaugeOpts{

Callers 1

Calls 2

queueInputRoomEventsMethod · 0.95
ErrorMethod · 0.45

Tested by 1