Handle requests concurrently

This commit is contained in:
Elara 2022-08-06 22:52:58 -07:00
parent d35a16ec64
commit 7592eae318
2 changed files with 72 additions and 70 deletions

View File

@ -133,7 +133,6 @@ func (s *Server) execute(pCtx context.Context, typ string, name string, data []b
arg = argVal.Elem().Interface()
ctx = newContext(pCtx, c)
// Get reflect value of context
ctxVal := reflect.ValueOf(ctx)
@ -304,6 +303,7 @@ func (s *Server) handleConn(pCtx context.Context, c codec.Codec) {
continue
}
go func() {
// Execute decoded call
val, ctx, err := s.execute(
pCtx,
@ -318,7 +318,7 @@ func (s *Server) handleConn(pCtx context.Context, c codec.Codec) {
valData, err := c.Marshal(val)
if err != nil {
s.sendErr(c, call, val, err)
continue
return
}
// Create response
@ -332,7 +332,7 @@ func (s *Server) handleConn(pCtx context.Context, c codec.Codec) {
idData, err := c.Marshal(ctx.channelID)
if err != nil {
s.sendErr(c, call, val, err)
continue
return
}
// Set IsChannel to true
@ -385,6 +385,8 @@ func (s *Server) handleConn(pCtx context.Context, c codec.Codec) {
c.Encode(res)
codecMtx.Unlock()
}
}()
}
}