objective categorical abstract machine language personal data server
65
fork

Configure Feed

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

Make handle dns resolution async, fall back to service proxy

futurGH 660b0925 b8fa1a0f

+17 -18
+1 -1
dune-project
··· 61 61 (caqti-lwt (>= 1.9.0)) 62 62 (cohttp (>= 6.1.1)) 63 63 (cohttp-lwt-unix (>= 6.1.1)) 64 - (dns-client (>= 10.2.0)) 64 + (dns-client-lwt (>= 10.2.0)) 65 65 dream 66 66 (emile (>= 1.1)) 67 67 (letters (>= 0.4.0))
+1 -1
pegasus.opam
··· 17 17 "caqti-lwt" {>= "1.9.0"} 18 18 "cohttp" {>= "6.1.1"} 19 19 "cohttp-lwt-unix" {>= "6.1.1"} 20 - "dns-client" {>= "10.2.0"} 20 + "dns-client-lwt" {>= "10.2.0"} 21 21 "dream" 22 22 "emile" {>= "1.1"} 23 23 "letters" {>= "0.4.0"}
+9 -11
pegasus/lib/api/identity/resolveHandle.ml
··· 1 + type query = {handle: string} [@@deriving yojson {strict= false}] 2 + 1 3 type response = {did: string} [@@deriving yojson {strict= false}] 2 4 3 5 let handler = 4 - Xrpc.handler (fun {req; db; _} -> 5 - let handle = 6 - match Dream.query req "handle" with 7 - | Some handle -> 8 - handle 9 - | None -> 10 - Errors.invalid_request "missing parameter 'handle'" 11 - in 12 - match%lwt Data_store.get_actor_by_identifier handle db with 6 + Xrpc.handler (fun ctx -> 7 + let {handle} = Xrpc.parse_query ctx.req query_of_yojson in 8 + match%lwt Data_store.get_actor_by_identifier handle ctx.db with 13 9 | Some actor -> 14 10 Dream.json @@ Yojson.Safe.to_string 15 11 @@ response_to_yojson {did= actor.did} ··· 17 13 match%lwt Id_resolver.Handle.resolve handle with 18 14 | Ok did -> 19 15 Dream.json @@ Yojson.Safe.to_string @@ response_to_yojson {did} 20 - | Error e -> 16 + | Error e -> ( 17 + try%lwt Xrpc.service_proxy ctx 18 + with _ -> 21 19 Dream.error (fun log -> log "%s" e) ; 22 - Errors.internal_error ~msg:"could not resolve handle" () ) ) 20 + Errors.internal_error ~msg:"could not resolve handle" () ) ) )
+1 -1
pegasus/lib/dune
··· 9 9 cohttp 10 10 cohttp-lwt-unix 11 11 core_unix 12 - dns-client.unix 12 + dns-client-lwt 13 13 dream 14 14 emile 15 15 frontend
+5 -4
pegasus/lib/id_resolver.ml
··· 1 1 open Cohttp_lwt 2 2 3 3 module Handle = struct 4 - let dns_client = Dns_client_unix.create () 4 + let dns_client = Dns_client_lwt.create (Happy_eyeballs_lwt.create ()) 5 5 6 6 let resolve_well_known handle = 7 7 try%lwt ··· 24 24 25 25 let resolve_dns handle = 26 26 try%lwt 27 - match 28 - Dns_client_unix.getaddrinfo dns_client Dns.Rr_map.Txt 27 + let%lwt result = 28 + Dns_client_lwt.getaddrinfo dns_client Dns.Rr_map.Txt 29 29 (Domain_name.of_string_exn ("_atproto." ^ handle)) 30 - with 30 + in 31 + match result with 31 32 | Ok (_, t) -> ( 32 33 let txt = Dns.Rr_map.Txt_set.choose t in 33 34 match String.split_on_char '=' txt with