123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Nomadic Labs, <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)moduletypeS=sigtypeviewtypecritical_errorvalrequest_error:(view*Worker_types.request_status*critical_error)Internal_event.Simple.tvalrequest_no_errors:(view*Worker_types.request_status)Internal_event.Simple.tvalterminated:unitInternal_event.Simple.tvaltriggering_shutdown:unitInternal_event.Simple.tvalcrashed:critical_errorInternal_event.Simple.tvalstarted:unitInternal_event.Simple.tvalstarted_for:stringInternal_event.Simple.tvalemit:'aInternal_event.Simple.t->'a->unitLwt.tendmoduletypeCRITICAL_ERROR=sigtypetvalencoding:tData_encoding.tvalpp:Format.formatter->t->unitendmoduleMake(N:Worker_intf.NAME)(R:Worker_intf.REQUEST)(C:CRITICAL_ERROR)=structincludeInternal_event.Simpletypeview=R.viewtypecritical_error=C.tletbase_name=String.concat"-"N.baseletsection=N.baseletrequest_error=declare_3~section~name:("request_"^base_name)~msg:"{view} {request_status} {errors}"~level:Debug~pp1:R.pp~pp2:Worker_types.pp_status~pp3:C.pp("view",Data_encoding.dynamic_sizeR.encoding)("request_status",Worker_types.request_status_encoding)("errors",C.encoding)letrequest_no_errors=declare_2~section~name:("request_no_errors_"^base_name)~msg:"{view} {request_status}"~level:Debug~pp1:R.pp~pp2:Worker_types.pp_status("view",R.encoding)("request_status",Worker_types.request_status_encoding)letterminated=declare_0~section~name:("terminate_"^base_name)~msg:(Format.asprintf"worker terminated [%s]"base_name)~level:Info()lettriggering_shutdown=declare_0~section~name:("triggering_"^base_name)~msg:"triggering shutting down"~level:Debug()letcrashed=declare_1~section~name:("crashed_"^base_name)~msg:(Format.asprintf"worker crashed [%s]: {error}"base_name)~level:Error~pp1:C.pp("error",C.encoding)letstarted=declare_0~section~name:("started_"^base_name)~msg:"worker started"~level:Info()letstarted_for=declare_1~section~name:("started_for_"^base_name)~msg:"worker started for {name}"~level:Info("name",Data_encoding.string)end