CCSDS 521.0-B-1 Mission Operations Message Abstraction Layer (MAL)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

mal: rename create_registry → registry, make_header → header (merlint E331)

+27 -27
+2 -2
lib/mal.ml
··· 290 290 mutable areas : area_def list; 291 291 } 292 292 293 - let create_registry () = 293 + let registry () = 294 294 { operations = Op_map.empty; handlers = Op_map.empty; areas = [] } 295 295 296 296 let register_area reg area = ··· 383 383 transaction_counter := Int64.add id 1L; 384 384 id 385 385 386 - let make_header ~uri_from ~uri_to ~interaction_type ~stage ~transaction_id ~area 386 + let header ~uri_from ~uri_to ~interaction_type ~stage ~transaction_id ~area 387 387 ~service ~operation ~body () = 388 388 { 389 389 uri_from;
+4 -4
lib/mal.mli
··· 243 243 type registry 244 244 (** A mutable service registry. *) 245 245 246 - val create_registry : unit -> registry 247 - (** [create_registry ()] creates an empty service registry. *) 246 + val registry : unit -> registry 247 + (** [registry ()] creates an empty service registry. *) 248 248 249 249 val register_area : registry -> area_def -> unit 250 250 (** [register_area reg area] registers all services and operations in [area]. *) ··· 326 326 Convenience functions that implement the message flows for each interaction 327 327 pattern. *) 328 328 329 - val make_header : 329 + val header : 330 330 uri_from:uri -> 331 331 uri_to:uri -> 332 332 interaction_type:interaction_type -> ··· 338 338 body:blob -> 339 339 unit -> 340 340 header 341 - (** [make_header ~uri_from ~uri_to ~interaction_type ~stage ~transaction_id 341 + (** [header ~uri_from ~uri_to ~interaction_type ~stage ~transaction_id 342 342 ~area ~service ~operation ~body ()] creates a header with default values 343 343 for QoS, priority, domain, session, etc. *) 344 344
+21 -21
test/test_mal.ml
··· 146 146 147 147 let test_header_roundtrip () = 148 148 let h = 149 - Mal.make_header ~uri_from:"mal:provider/1" ~uri_to:"mal:consumer/2" 149 + Mal.header ~uri_from:"mal:provider/1" ~uri_to:"mal:consumer/2" 150 150 ~interaction_type:Mal.Request ~stage:Mal.Request_stage ~transaction_id:42L 151 151 ~area:1 ~service:2 ~operation:3 ~body:"hello" () 152 152 in ··· 170 170 171 171 let test_header_equality () = 172 172 let h1 = 173 - Mal.make_header ~uri_from:"mal:a" ~uri_to:"mal:b" ~interaction_type:Mal.Send 173 + Mal.header ~uri_from:"mal:a" ~uri_to:"mal:b" ~interaction_type:Mal.Send 174 174 ~stage:Mal.Send_stage ~transaction_id:1L ~area:1 ~service:1 ~operation:1 175 175 ~body:"" () 176 176 in 177 177 let h2 = 178 - Mal.make_header ~uri_from:"mal:a" ~uri_to:"mal:b" ~interaction_type:Mal.Send 178 + Mal.header ~uri_from:"mal:a" ~uri_to:"mal:b" ~interaction_type:Mal.Send 179 179 ~stage:Mal.Send_stage ~transaction_id:1L ~area:1 ~service:1 ~operation:1 180 180 ~body:"" () 181 181 in ··· 188 188 let consumer = Mal.Mem_transport.create "mal:consumer" in 189 189 let provider = Mal.Mem_transport.create "mal:provider" in 190 190 let msg = 191 - Mal.make_header ~uri_from:"mal:provider" ~uri_to:"mal:consumer" 191 + Mal.header ~uri_from:"mal:provider" ~uri_to:"mal:consumer" 192 192 ~interaction_type:Mal.Send ~stage:Mal.Send_stage ~transaction_id:1L 193 193 ~area:1 ~service:1 ~operation:1 ~body:"fire-and-forget" () 194 194 in ··· 212 212 let tid = Mal.next_transaction_id () in 213 213 (* Consumer submits *) 214 214 let submit = 215 - Mal.make_header ~uri_from:"mal:consumer" ~uri_to:"mal:provider" 215 + Mal.header ~uri_from:"mal:consumer" ~uri_to:"mal:provider" 216 216 ~interaction_type:Mal.Submit ~stage:Mal.Submit_stage ~transaction_id:tid 217 217 ~area:1 ~service:1 ~operation:1 ~body:"submit-request" () 218 218 in ··· 228 228 Alcotest.(check (of_pp Mal.pp_stage)) 229 229 "received stage" Mal.Submit_stage received.stage; 230 230 let ack = 231 - Mal.make_header ~uri_from:"mal:provider" ~uri_to:"mal:consumer" 231 + Mal.header ~uri_from:"mal:provider" ~uri_to:"mal:consumer" 232 232 ~interaction_type:Mal.Submit ~stage:Mal.Submit_ack ~transaction_id:tid 233 233 ~area:1 ~service:1 ~operation:1 ~body:"" () 234 234 in ··· 254 254 let tid = Mal.next_transaction_id () in 255 255 (* Consumer sends request *) 256 256 let req = 257 - Mal.make_header ~uri_from:"mal:consumer" ~uri_to:"mal:provider" 257 + Mal.header ~uri_from:"mal:consumer" ~uri_to:"mal:provider" 258 258 ~interaction_type:Mal.Request ~stage:Mal.Request_stage ~transaction_id:tid 259 259 ~area:2 ~service:1 ~operation:1 ~body:"get-something" () 260 260 in ··· 268 268 | Error e -> Alcotest.failf "recv failed: %a" Mal.pp_error_code e 269 269 in 270 270 let resp = 271 - Mal.make_header ~uri_from:"mal:provider" ~uri_to:"mal:consumer" 271 + Mal.header ~uri_from:"mal:provider" ~uri_to:"mal:consumer" 272 272 ~interaction_type:Mal.Request ~stage:Mal.Request_response 273 273 ~transaction_id:tid ~area:2 ~service:1 ~operation:1 ~body:"here-it-is" () 274 274 in ··· 294 294 let provider = Mal.Mem_transport.create "mal:provider" in 295 295 let tid = Mal.next_transaction_id () in 296 296 let mk stage body = 297 - Mal.make_header ~uri_from:"mal:consumer" ~uri_to:"mal:provider" 297 + Mal.header ~uri_from:"mal:consumer" ~uri_to:"mal:provider" 298 298 ~interaction_type:Mal.Invoke ~stage ~transaction_id:tid ~area:1 ~service:1 299 299 ~operation:1 ~body () 300 300 in 301 301 let mk_resp stage body = 302 - Mal.make_header ~uri_from:"mal:provider" ~uri_to:"mal:consumer" 302 + Mal.header ~uri_from:"mal:provider" ~uri_to:"mal:consumer" 303 303 ~interaction_type:Mal.Invoke ~stage ~transaction_id:tid ~area:1 ~service:1 304 304 ~operation:1 ~body () 305 305 in ··· 340 340 let provider = Mal.Mem_transport.create "mal:provider" in 341 341 let tid = Mal.next_transaction_id () in 342 342 let mk_consumer stage body = 343 - Mal.make_header ~uri_from:"mal:consumer" ~uri_to:"mal:provider" 343 + Mal.header ~uri_from:"mal:consumer" ~uri_to:"mal:provider" 344 344 ~interaction_type:Mal.Progress ~stage ~transaction_id:tid ~area:1 345 345 ~service:1 ~operation:1 ~body () 346 346 in 347 347 let mk_provider stage body = 348 - Mal.make_header ~uri_from:"mal:provider" ~uri_to:"mal:consumer" 348 + Mal.header ~uri_from:"mal:provider" ~uri_to:"mal:consumer" 349 349 ~interaction_type:Mal.Progress ~stage ~transaction_id:tid ~area:1 350 350 ~service:1 ~operation:1 ~body () 351 351 in ··· 405 405 let tid_sub = Mal.next_transaction_id () in 406 406 let tid_pub = Mal.next_transaction_id () in 407 407 let mk from_uri to_uri stage tid body = 408 - Mal.make_header ~uri_from:from_uri ~uri_to:to_uri 408 + Mal.header ~uri_from:from_uri ~uri_to:to_uri 409 409 ~interaction_type:Mal.Pub_sub ~stage ~transaction_id:tid ~area:1 410 410 ~service:1 ~operation:1 ~body () 411 411 in ··· 480 480 (* {1 Service registration and dispatch} *) 481 481 482 482 let test_service_registration () = 483 - let reg = Mal.create_registry () in 483 + let reg = Mal.registry () in 484 484 let area = 485 485 { 486 486 Mal.area_name = "COM"; ··· 527 527 (is_infix ~affix:"EventService" s) 528 528 529 529 let test_dispatch () = 530 - let reg = Mal.create_registry () in 530 + let reg = Mal.registry () in 531 531 let area = 532 532 { 533 533 Mal.area_name = "MC"; ··· 565 565 Mal.register_handler reg ~area:4 ~service:1 ~operation:1 handler; 566 566 (* Dispatch a message *) 567 567 let req = 568 - Mal.make_header ~uri_from:"mal:consumer" ~uri_to:"mal:provider" 568 + Mal.header ~uri_from:"mal:consumer" ~uri_to:"mal:provider" 569 569 ~interaction_type:Mal.Request ~stage:Mal.Request_stage 570 570 ~transaction_id:100L ~area:4 ~service:1 ~operation:1 ~body:"get-param" () 571 571 in ··· 580 580 | Error e -> Alcotest.failf "dispatch failed: %a" Mal.pp_error_code e); 581 581 (* Dispatch to unknown area *) 582 582 let bad_area = 583 - Mal.make_header ~uri_from:"mal:c" ~uri_to:"mal:p" 583 + Mal.header ~uri_from:"mal:c" ~uri_to:"mal:p" 584 584 ~interaction_type:Mal.Request ~stage:Mal.Request_stage 585 585 ~transaction_id:101L ~area:99 ~service:1 ~operation:1 ~body:"" () 586 586 in ··· 589 589 (Mal.dispatch reg bad_area); 590 590 (* Dispatch to unknown service *) 591 591 let bad_svc = 592 - Mal.make_header ~uri_from:"mal:c" ~uri_to:"mal:p" 592 + Mal.header ~uri_from:"mal:c" ~uri_to:"mal:p" 593 593 ~interaction_type:Mal.Request ~stage:Mal.Request_stage 594 594 ~transaction_id:102L ~area:4 ~service:99 ~operation:1 ~body:"" () 595 595 in ··· 597 597 "unknown service" (Error Mal.Unsupported_service) (Mal.dispatch reg bad_svc); 598 598 (* Dispatch to unhandled operation *) 599 599 let bad_op = 600 - Mal.make_header ~uri_from:"mal:c" ~uri_to:"mal:p" 600 + Mal.header ~uri_from:"mal:c" ~uri_to:"mal:p" 601 601 ~interaction_type:Mal.Request ~stage:Mal.Request_stage 602 602 ~transaction_id:103L ~area:4 ~service:1 ~operation:99 ~body:"" () 603 603 in ··· 611 611 Mal.Mem_transport.reset (); 612 612 let sender = Mal.Mem_transport.create "mal:sender" in 613 613 let msg = 614 - Mal.make_header ~uri_from:"mal:sender" ~uri_to:"mal:nonexistent" 614 + Mal.header ~uri_from:"mal:sender" ~uri_to:"mal:nonexistent" 615 615 ~interaction_type:Mal.Send ~stage:Mal.Send_stage ~transaction_id:1L 616 616 ~area:1 ~service:1 ~operation:1 ~body:"" () 617 617 in ··· 632 632 let sender = Mal.Mem_transport.create "mal:sender2" in 633 633 Mal.Mem_transport.close ep; 634 634 let msg = 635 - Mal.make_header ~uri_from:"mal:sender2" ~uri_to:"mal:closing" 635 + Mal.header ~uri_from:"mal:sender2" ~uri_to:"mal:closing" 636 636 ~interaction_type:Mal.Send ~stage:Mal.Send_stage ~transaction_id:1L 637 637 ~area:1 ~service:1 ~operation:1 ~body:"" () 638 638 in