HandleStateReadRequest() handles an inbound state read request from a specific FSM context
(msg *PluginToFSM)
| 311 | |
| 312 | // HandleStateReadRequest() handles an inbound state read request from a specific FSM context |
| 313 | func (p *Plugin) handleStateReadRequest(msg *PluginToFSM) ErrorI { |
| 314 | // debug log state read request start |
| 315 | p.log.Debugf("handleStateReadRequest() processing message ID %d", msg.Id) |
| 316 | // get the FSM context for this request ID |
| 317 | p.l.Lock() |
| 318 | fsm := p.requestFSMs[msg.Id] |
| 319 | // debug log FSM lookup |
| 320 | p.log.Debugf("handleStateReadRequest() FSM lookup for ID %d: found=%t, total_fsms=%d", msg.Id, fsm != nil, len(p.requestFSMs)) |
| 321 | p.l.Unlock() |
| 322 | // debug log request details |
| 323 | request := msg.GetStateRead() |
| 324 | p.log.Debugf("handleStateReadRequest() state read request: %+v", request) |
| 325 | // check if FSM context exists |
| 326 | if fsm == nil { |
| 327 | p.log.Debugf("handleStateReadRequest() no FSM context found for request ID %d", msg.Id) |
| 328 | return ErrInvalidPluginRespId() |
| 329 | } |
| 330 | // forward request to the appropriate FSM |
| 331 | p.log.Debug("handleStateReadRequest() forwarding request to FSM") |
| 332 | response, err := fsm.StateRead(request) |
| 333 | if err != nil { |
| 334 | p.log.Debugf("handleStateReadRequest() FSM StateRead error: %v", err) |
| 335 | response.Error = NewPluginError(err) |
| 336 | } else { |
| 337 | p.log.Debugf("handleStateReadRequest() FSM StateRead success: %+v", response) |
| 338 | } |
| 339 | // send response back to FSM |
| 340 | p.log.Debugf("handleStateReadRequest() sending response back for message ID %d", msg.Id) |
| 341 | sendErr := p.sendProtoMsg(&FSMToPlugin{ |
| 342 | Id: msg.Id, |
| 343 | Payload: &FSMToPlugin_StateRead{ |
| 344 | StateRead: &response, |
| 345 | }, |
| 346 | }) |
| 347 | if sendErr != nil { |
| 348 | p.log.Debugf("handleStateReadRequest() error sending response: %v", sendErr) |
| 349 | } else { |
| 350 | p.log.Debug("handleStateReadRequest() response sent successfully") |
| 351 | } |
| 352 | return sendErr |
| 353 | } |
| 354 | |
| 355 | // HandleStateWriteRequest() handles an inbound state write request from a specific FSM context |
| 356 | func (p *Plugin) handleStateWriteRequest(msg *PluginToFSM) ErrorI { |
no test coverage detected