This commit is contained in:
Benedetta 2024-04-24 09:58:14 +02:00
parent a1679df6a6
commit d747aa1cca
2 changed files with 12 additions and 1 deletions

View file

@ -1,4 +1,5 @@
open Pam.Datatypes
open Pam.Issue_parser
open Batteries
open Utils
@ -11,14 +12,22 @@ let _HTTP_CLIENT = "http_client"
**)
let http_client (repos: Config.repo_data list) =
let http_actor = Httpclient.init repos in
let _ = print_endline "Initialized http client" in
let rec loop () =
let _ =
match Riot.receive () with
| ListIssues ->
Httpclient.make_get_request http_actor
|> Result.map Pam.Datatypes.forgejo_issues
(* |> Result.map Pam.Datatypes.forgejo_issues *)
|> Result.bind (fun issue ->
match to_datetime issue with
| Error e -> Error e |> Option.some
| Ok None -> None
| Ok (Some times) -> failwith "dunno"
)
|> Result.map_error Pam.Datatypes.internal_failure
|> Result.fold ~ok:identity ~error:(fun e -> [e])
|> List.map (Riot.send_by_name ~name:_MQ_CLIENT)

View file

@ -20,3 +20,5 @@ let one_second = 1_000_000L
let exit2 msg = let _ = print_endline msg in exit 2
module StringMap = Map.Make (String)
let rec all acc = function [] -> Ok acc | Ok x::xs -> all (x::acc) xs | Error e::_ -> Error e