<commit_before>let ( >>= ) = Lwt.( >>= )

let log_fix_message pre msg =
  let log = Fix_io.encode ~split:'|' msg in
  Lwt_io.printlf "[%s]: %s" pre log


let fixio_to_engine engine msg =
  log_fix_message "In " msg
  >>= fun () ->
  let msg = Parse_full_messages.parse_top_level_msg msg in
  Engine.send_fix engine msg


let engine_to_fixio fixio msg =
  let wire = Encode_full_messages.packet_full_valid_msg msg in
  log_fix_message "Out" wire >>= fun () -> Fix_io.send fixio wire


let rec loop (fixio_box, fixio) (engine_box, engine) (model_box, model) =
  Lwt.pick
    [ ( Lwt_mvar.take engine_box
      >>= function
      | Engine.FIXMessage (Full_messages.ValidMsg msg) ->
        Lwt_io.printl "Engine.FIXMessage" >>= fun () -> Lwt_io.flush_all () >>= fun () ->
        engine_to_fixio fixio msg
      | Engine.OutFIXData (_,msg) ->
        Lwt_io.printl "Engine.OutFIXData" >>= fun () -> Lwt_io.flush_all () >>= fun () ->
        Model.send_fix model (OutIntMsg_ApplicationData msg) 
      | _ ->
          Lwt.return_unit )
    ; (Lwt_mvar.take fixio_box >>= fun msg ->
       Lwt_io.printl "fixio_box" >>= fun () -> Lwt_io.flush_all () >>= 
      fun () -> fixio_to_engine engine msg)
    ; ( Lwt_mvar.take model_box
      >>= function
      | Model.FIXMessage msg ->
        Lwt_io.printl "Model.FIXMessage" >>= fun () -> Lwt_io.flush_all () >>= fun () ->
        Engine.send_int engine msg
      | _ ->
          Lwt.return_unit )
    ]
  >>= fun () -> loop (fixio_box, fixio) (engine_box, engine) (model_box, model)<commit_msg>log biz/session rejects<commit_after>let ( >>= ) = Lwt.( >>= )

let log_fix_message pre msg =
  let log = Fix_io.encode ~split:'|' msg in
  Lwt_io.printlf "[%s]: %s" pre log


let fixio_to_engine engine msg =
  log_fix_message "In " msg
  >>= fun () ->
  let msg = Parse_full_messages.parse_top_level_msg msg in
  Engine.send_fix engine msg


let engine_to_fixio fixio msg =
  let wire = Encode_full_messages.packet_full_valid_msg msg in
  log_fix_message "Out" wire >>= fun () -> Fix_io.send fixio wire


let rec loop (fixio_box, fixio) (engine_box, engine) (model_box, model) =
  Lwt.pick
    [ ( Lwt_mvar.take engine_box
      >>= function
      | Engine.FIXMessage (Full_messages.ValidMsg msg) -> 
        Lwt_io.printl "Engine.FIXMessage ValidMsg" >>= fun () -> Lwt_io.flush_all () >>= fun () ->
        engine_to_fixio fixio msg 
      | Engine.FIXMessage (Full_messages.Garbled ) ->
        Lwt_io.printl "Engine.FIXMessage Garbled" >>= fun () -> Lwt_io.flush_all ()
      | Engine.FIXMessage (Full_messages.SessionRejectedMsg m ) ->
        Lwt_io.printl "Engine.FIXMessage SessionRejectedMsg" >>= fun () -> Lwt_io.flush_all () >>= fun () ->
        Lwt_io.printl (Full_messages_json.session_rejected_msg_to_json m |> Yojson.Basic.to_string) >>= fun () -> Lwt_io.flush_all ()
      | Engine.FIXMessage (Full_messages.BusinessRejectedMsg m ) ->
        Lwt_io.printl "Engine.FIXMessage BusinessRejectedMsg" >>= fun () -> Lwt_io.flush_all () >>= fun () ->
        Lwt_io.printl (Full_messages_json.biz_rejected_msg_to_json m |> Yojson.Basic.to_string) >>= fun () -> Lwt_io.flush_all ()
      | Engine.OutFIXData (_,msg) -> 
        Lwt_io.printl "Engine.OutFIXData" >>= fun () -> Lwt_io.flush_all () >>= fun () ->
        Model.send_fix model (OutIntMsg_ApplicationData msg)
      | Engine.State _ -> 
        Lwt_io.printl "Engine.State" >>= fun () -> Lwt_io.flush_all () 
      )
    ; ( Lwt_mvar.take fixio_box >>= fun msg ->
        Lwt_io.printl "fixio_box" >>= fun () -> Lwt_io.flush_all () >>= 
        fun () -> fixio_to_engine engine msg
      )
    ; ( Lwt_mvar.take model_box
      >>= function
      | Model.FIXMessage msg ->
        Lwt_io.printl "Model.FIXMessage" >>= fun () -> Lwt_io.flush_all () >>= fun () ->
        Engine.send_int engine msg
      | Model.State _ ->
        Lwt_io.printl "Model.State" >>= fun () -> Lwt_io.flush_all () 
      )
    ]
  >>= fun () -> loop (fixio_box, fixio) (engine_box, engine) (model_box, model)
{'fraction_non_alphanumeric': 0.14610958218663997, 'fraction_numerical': 0.0, 'mean_word_length': 2.859073359073359, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 133, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5298858', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1447, 'n_words': 285}