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