exec executes the given request and writes the result back using the codec.
(ctx context.Context, codec ServerCodec, req *serverRequest)
| 325 | |
| 326 | // exec executes the given request and writes the result back using the codec. |
| 327 | func (s *Server) exec(ctx context.Context, codec ServerCodec, req *serverRequest) { |
| 328 | var response interface{} |
| 329 | var callback func() |
| 330 | if req.err != nil { |
| 331 | response = codec.CreateErrorResponse(&req.id, req.err) |
| 332 | } else { |
| 333 | response, callback = s.handle(ctx, codec, req) |
| 334 | } |
| 335 | |
| 336 | if err := codec.Write(response); err != nil { |
| 337 | log.Error(fmt.Sprintf("%v\n", err)) |
| 338 | codec.Close() |
| 339 | } |
| 340 | |
| 341 | // when request was a subscribe request this allows these subscriptions to be actived |
| 342 | if callback != nil { |
| 343 | callback() |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | // execBatch executes the given requests and writes the result back using the codec. |
| 348 | // It will only write the response back when the last request is processed. |
no test coverage detected