From f59749f0118807502618e25fba89c7a3fd083b54 Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Mon, 25 Nov 2024 00:20:05 -0300 Subject: lwt socket server --- lib/dune | 2 +- lib/relation.ml | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/dune b/lib/dune index 8ad4a95..5b495a2 100644 --- a/lib/dune +++ b/lib/dune @@ -1,6 +1,6 @@ (library (name relational_engine) - (libraries ctypes ctypes-foreign data-encoding) + (libraries ctypes ctypes-foreign data-encoding lwt lwt.unix lwt_log) (preprocess (pps ppx_deriving.show ppx_sexp_conv)) ;; (c_library_flags -lssl -lcrypto -L %{env:LIBRESSL_LIB_PATH=}) ;; (foreign_stubs diff --git a/lib/relation.ml b/lib/relation.ml index a4e14c4..1854875 100644 --- a/lib/relation.ml +++ b/lib/relation.ml @@ -1,9 +1,14 @@ open Sexplib0 open Sexplib0.Sexp_conv -open Ppx_xml_conv + module Protocol = struct - type tuples = string list list - [@@deriving sexp, ] + type tuple = string list [@@deriving sexp] + type relation = + { attribute_name: string; + attribute_type: string; + tuples: tuple } + [@@deriving sexp] + type t = relation list [@@deriving sexp] end let write_and_retrieve() = @@ -35,5 +40,6 @@ let write_and_retrieve() = let+ (_, Command.Read last_name) = Command.commit_and_perform (List.tl stream) locations command_read2 in (* List.iter (fun a -> print_endline a) (List.map Bytes.to_string first_name); *) (* List.iter (fun a -> print_endline a) (List.map Bytes.to_string last_name); *) - Ok (Sexp.to_string (Protocol.sexp_of_tuples [List.map Bytes.to_string first_name; List.map Bytes.to_string last_name])) + Ok (Sexp.to_string (Protocol.sexp_of_t [{attribute_name = "user/first-name"; attribute_type = "string"; tuples = List.map Bytes.to_string first_name}; + {attribute_name = "user/last-name"; attribute_type = "string"; tuples = List.map Bytes.to_string last_name}])) [@@warning "-8"] (* Suppress pattern match incomplete warnings *) -- cgit v1.2.3