aboutsummaryrefslogtreecommitdiffstats
path: root/bin/server.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-04-22 22:46:41 -0300
committerGitHub <noreply@github.com>2026-04-22 22:46:41 -0300
commit29e00769046cbc8cd020b2b7c47448d89f21ab39 (patch)
treedf6601daa94f7d588708ceca5a34fa02b75d791b /bin/server.ml
parentfdc63e730f91a4605ed4ff96a908e1f5e822d1bb (diff)
downloadSakura-29e00769046cbc8cd020b2b7c47448d89f21ab39.tar.gz
Sakura-29e00769046cbc8cd020b2b7c47448d89f21ab39.zip
Prototype for configuration
Diffstat (limited to 'bin/server.ml')
-rw-r--r--bin/server.ml101
1 files changed, 9 insertions, 92 deletions
diff --git a/bin/server.ml b/bin/server.ml
index 1d4d5b3..2423c37 100644
--- a/bin/server.ml
+++ b/bin/server.ml
@@ -1,95 +1,12 @@
open Relational_engine
-module B = Management.Physical.Memory
-module T = Transport.TCP
-module Listener = Listener.Make(T)(B)
-
-module Memory = Manipulation.Make (B)
-
-(* TODO: registration failures are silently ignored; a broken prelude
- relation leaves the catalog in a partially-seeded state with no
- indication to the user. *)
-(* TODO: think of a better way to initialize new databases *)
-let register_prelude_relations storage db =
- let open Prelude.Standard in
- List.fold_left
- (fun db (rel : Relation.t) ->
- match
- Memory.create_immutable_relation storage db ~name:rel.name
- ~schema:rel.schema ~generator:(Option.get rel.generator)
- ~membership_criteria:rel.membership_criteria
- ~cardinality:rel.cardinality
- with
- | Ok (new_db, _) -> new_db
- | Error e ->
- Printf.eprintf
- "Warning: failed to register prelude relation %s: %s\n%!" rel.name
- (Sexplib.Sexp.to_string (Error.sexp_of_error e));
- db)
- db
- [
- less_than_natural;
- less_than_or_equal_natural;
- greater_than_natural;
- greater_than_or_equal_natural;
- equal_natural;
- not_equal_natural;
- plus_natural;
- times_natural;
- minus_natural;
- divide_natural;
- ]
-
-(* let register_branch_relations storage db = *)
-(* (\* Register ephemeral sakura:branch and sakura:head relations backed by *)
-(* the raw branch registry — no stored tuples, no circularity. *\) *)
-(* let register db rel = *)
-(* match *)
-(* Memory.create_immutable_relation storage db *)
-(* ~name:rel.Relation.name ~schema:rel.Relation.schema *)
-(* ~generator:(Option.get rel.Relation.generator) *)
-(* ~membership_criteria:rel.Relation.membership_criteria *)
-(* ~cardinality:rel.Relation.cardinality *)
-(* with *)
-(* | Ok (db, _) -> db *)
-(* | Error e -> *)
-(* Printf.eprintf "Warning: failed to register %s: %s\n%!" *)
-(* rel.Relation.name *)
-(* (Manipulation.Error.string_of_error e); *)
-(* db *)
-(* in *)
-(* db *)
-(* |> Fun.flip register (BranchOps.branch_relation storage) *)
-(* |> Fun.flip register (BranchOps.head_relation storage) *)
-
-let setup () =
- let ( let* ) = Result.bind in
- let* storage =
- Management.Physical.Memory.create ()
- |> Result.map_error (Fun.const "Failed to create storage")
- in
- let* db =
- Memory.create_database storage ~name:"sakura"
- |> Result.map_error (Fun.const "Failed to create initial database")
- in
- Ok (storage, db)
-
-let address = "127.0.0.1"
-let port = 7777
-
let () =
- match setup () with
- | Error msg -> Printf.eprintf "Couldn't initialize: %s" msg
- | Ok (storage, db) ->
- let db =
- db
- |> register_prelude_relations storage
- (* |> register_branch_relations storage *)
- in
- let transport =
- T.create
- { address_family = Unix.PF_INET;
- address = Unix.ADDR_INET (Unix.inet_addr_of_string address, port) }
- in
- Printf.printf "Listening on %s:%d" address port; print_newline ();
- Listener.run transport db storage
+ if Array.length Sys.argv <> 2 then begin
+ Printf.eprintf "Usage: %s <config-file>\n%!" Sys.argv.(0);
+ exit 1;
+ end;
+ match System.run_from_config Sys.argv.(1) with
+ | Error e ->
+ Printf.eprintf "Couldn't initialize: %s\n%!" e;
+ exit 1
+ | Ok run -> run ()