Upsycle_routerThis is the top-level entrypoint module for Upsycle_router.
The entire Commons module is re-exported through the top level.
module Commons : sig ... endContains shared types and values which are used throughout the application.
type 'a rresult = ('a, result_msg) Stdlib.resulttype 'a of_yaml = Yaml.value -> 'a rresultThese are the base types we use for private and public keys; no need to try and hide the implementation.
Used for choosing the Blake2 hash function for calculating message IDs.
When the message router receives a JOIN request whose src field doesn't match the actual public key of the peer, it needs to decide which one to actually add to the group. By default this is set to `Src in the configurations, but `Peerkey can be useful for testing or experimenting.
Configures whether or not to dump the contents of every message received by the message router to the console.
type multicast_table =
  (multicast_group_pubkey, multicast_subscriber BatSet.t) BatMap.tThe functions in T are just function versions of the constructors of various types, which provides a convenient way of constructing types in many situations.
module T : sig ... endmodule Pp : sig ... endmodule Encode : sig ... endmodule Decode : sig ... endmodule Crypto : sig ... endmodule Yaml : sig ... endmodule Mk : sig ... endmodule Acc : sig ... endProvides handlers for the keys 'q', '\n', and an unknown key press, to be used in the key thread.
Returns a random integer for use in the `ttl` field.
mk_random_ttl `Short produces an integer in the range [3, 10].
mk_random_ttl `Medium produces an integer in the range [10, 30].
Returns a random integer representing minutes elapsed since 2020-01-01 00:00 UTC, for use in the `expiry` field.
Returns a random integer in the range [0, 19], for use in the `revision` field.
val to_yaml_noop : 'a Util_yaml.to_yamlppx_deriving_yaml requires both an x_to_yaml and x_of_yaml function for a type x in order to be able produce derivations for types which include x. However the 'of_yaml' variant is never used in this library so there's no sense in writing it; this function can be provided instead to satisfy the requirements.
val error_msg : string -> string rresultConvenience for generating Error (`Msg s) from a string s.
val pubkey_of_multicast_group : multicast_group -> pubkeyval string_list_of_command : command -> string listMessage_router_config and Service_config are used for configuring an executable which uses this library code. See the code for upsycle-router.exe and upsycle-service.exe in the bin directory for usage.
module Message_router_config : sig ... endmodule Service_config : sig ... endtype timer_handler :=
  expired:bool ->
  ([ `Multi | `Uni ] * Commons.pubkey * Message.Base.t) ->
  unitInitialize the cryptography functions in Mirage_crypto_rng (calls Mirage_crypto_rng_lwt.initialize underneath). It's important to call this during initialization, before using any of those functions.
Note that the message router keeps track of its own mutable state as a singleton, which saves us from having to manually keep track of the state and pass it to all the functions. It also means that you can only start one message router per process.
val start_message_router : 
  ?threads:
    (Message_router_config.t ->
      (Upsycle_router__.Message_router_stream.stream_msg option -> unit) ->
      unit Lwt.t)
      list ->
  Message_router_config.t ->
  unit Lwt.tval serialize_message_router_state : Message_router_config.t -> unit Lwt.tval deserialize_and_set_message_router_state : 
  timer_handler ->
  int ->
  int ->
  string ->
  unit Lwt.tval send_peer_advertisement_about_us : 
  Message_router_config.t ->
  addr_type:[ `Tcp ] ->
  rev:int ->
  ttl_multicast:int ->
  ttl_pa:int ->
  exp_multicast:int ->
  exp_pa:int ->
  string ->
  pubkey ->
  [> `No_groups | `Ok of int ] Lwt.tval get_connection : 
  Commons.pubkey ->
  Upsycle_router__.Message_router_route.connection optionval get_groups_from_multicast_table : unit -> multicast_group_pubkey listval unqueue_message : 
  expired:bool ->
  Commons.msg_id_hash_function ->
  ([ `Multi | `Uni ] * pubkey * Message.Base.t) ->
  unitThis refers to either message routers or services who want to communicate with a remote message router.
val send_message_to_peer : 
  ttl:int ->
  exp:int ->
  body:string ->
  pubkey Util_conduit.connection ->
  privkey ->
  pubkey ->
  pubkey ->
  unit Lwt.tval send_join_to_message_router : 
  ttl:int ->
  exp:int ->
  'a Util_conduit.connection ->
  privkey ->
  pubkey ->
  pubkey ->
  pubkey ->
  unit Lwt.tval send_message_to_topic : 
  ttl:int ->
  exp:int ->
  seen:Message.Com.seen ->
  'a Util_conduit.connection ->
  multicast_group_rw ->
  string ->
  unit Lwt.tval send_message_to_topic_of_remote_router : 
  ttl:int ->
  exp:int ->
  seen:Message.Com.seen ->
  pubkey:pubkey ->
  multicast_group_rw ->
  string ->
  unit Lwt.tIn the case of services the caller is responsible for keeping track of the state and most functions accept a state reference which they will mutate or query.
val start_service : 
  ?threads:
    (Service_config.t ->
      Upsycle_router__.Service.State.state Stdlib.ref ->
      pubkey Util_conduit.Connection.t ->
      unit Lwt.t)
      list ->
  Service_config.t ->
  unit Lwt.tval join_groups : 
  ?prepend:string ->
  ttl:int ->
  exp:int ->
  Service_config.t ->
  Upsycle_router__.Service.State.state Stdlib.ref ->
  'a Util_conduit.Connection.t ->
  multicast_group list ->
  join_leave_return Lwt.tval leave_all_groups : 
  ?prepend:string ->
  ttl:int ->
  exp:int ->
  Service_config.t ->
  Upsycle_router__.Service.State.state Stdlib.ref ->
  'a Util_conduit.Connection.t ->
  join_leave_return Lwt.tval publish_to_subscribed_groups : 
  ?prepend:string ->
  ttl:int ->
  exp:int ->
  Service_config.t ->
  Upsycle_router__.Service.State.state Stdlib.ref ->
  'a Util_conduit.Connection.t ->
  publish_return Lwt.tval pull_seen : 
  ?prepend:string ->
  ttl:int ->
  exp:int ->
  Service_config.t ->
  Upsycle_router__.Service.State.state Stdlib.ref ->
  'a Util_conduit.Connection.t ->
  pull_seen_return Lwt.tval service_show_state : 
  Service_config.t ->
  Upsycle_router__.Service.State.state Stdlib.ref ->
  string ->
  unit Lwt.tval mk_encoded_multicast_message : 
  ttl:int ->
  exp:int ->
  seen:Message.Com.seen ->
  multicast_group_rw ->
  string ->
  stringval mk_unicast_message : 
  ?test_tamper:bool ->
  ttl:int ->
  exp:int ->
  ?via:pubkey ->
  (privkey * pubkey) ->
  pubkey ->
  string ->
  Message.Base.tval mk_multicast_message : 
  ?test_tamper:bool ->
  ttl:int ->
  exp:int ->
  ?via:pubkey ->
  seen:Message.Com.seen ->
  multicast_group_rw ->
  string ->
  Message.Base.tval mk_encoded_peer_advertisement_message : 
  ?test_tamper:bool ->
  id:pubkey ->
  (Commons.ip * port * [ `Tcp ]) ->
  (pubkey option * pubkey option) ->
  grps:multicast_group_pubkey list ->
  rev:int ->
  ttl:int ->
  exp:int ->
  priv_key:privkey ->
  stringval mk_privkey_base64_exn : string -> privkeyval mk_pubkey_base64_exn : string -> pubkeyval mk_seen : int -> Message.Com.seenval parse_conduit_stream : 
  'a Util_conduit.Connection.t ->
  int ->
  (Message.Base.t -> bool Lwt.t) ->
  (unit -> bool Lwt.t) ->
  (string -> [< `Fail | `Scrub of int ] Lwt.t) ->
  (string -> unit Lwt.t) ->
  unit Lwt.tval stream_msg : 
  Upsycle_router__.Message_router_route.connection ->
  Util_conduit.info ->
  pubkey ->
  pubkey ->
  Message.Base.t ->
  Upsycle_router__.Message_router_stream.stream_msgval test_stream_msg : 
  Util_conduit.info ->
  pubkey ->
  pubkey ->
  Message.Base.t ->
  Upsycle_router__.Message_router_stream.stream_msgWe flatten this module so that [@@deriving yaml] works transparently from the outside.
include module type of Commons.Yamlval host_port_to_yaml : Commons.host_port Commons.to_yamlval host_port_of_yaml : Commons.host_port Commons.of_yamlval ip_of_yaml : Commons.ip Commons.of_yamlval ip_to_yaml : Commons.ip Commons.to_yamlval port_of_yaml : Commons.port Commons.of_yamlval port_to_yaml : Commons.port Commons.to_yamlval ip_port_of_yaml : Commons.ip_port Commons.of_yamlval ip_port_to_yaml : Commons.ip_port Commons.to_yamlval print_messages_on_console_of_yaml : 
  [ `Long | `None | `Short ] Commons.of_yamlval print_messages_on_console_to_yaml : 'a Commons.to_yamlval pubkey_of_file_of_yaml : Commons.pubkey Commons.of_yamlval multicast_requestor_of_yaml : Commons.multicast_requestor Commons.of_yamlval multicast_requestor_to_yaml : Commons.multicast_requestor Commons.to_yamlval msg_id_hash_function_of_yaml : Commons.msg_id_hash_function Commons.of_yamlval msg_id_hash_function_to_yaml : Commons.msg_id_hash_function Commons.to_yamlval multicast_group_of_yaml : Commons.multicast_group Commons.of_yamlval string_of_file_of_yaml : string Commons.of_yamlval command_of_yaml : Commons.command Commons.of_yamlval command_to_yaml : Commons.command Commons.to_yamlval string_or_string_list_of_yaml : string_or_string_list Commons.of_yamlval string_or_string_list_to_yaml : string_or_string_list Commons.to_yamlWe export the Message module here, which may be useful for constructing and understanding the various kinds of messages. It's generally not necessary to use this module directly.
module Message : sig ... endWe export Basic and all the utils here for convenience and for better documentation, though they are also available directly as libraries. Basic is imported using open by nearly every module.
module Basic : sig ... endmodule Util_cache : sig ... endmodule Util_conduit : sig ... endmodule Util_crypto_io : sig ... endmodule Util_crypto : sig ... endmodule Util_encode_decode_io : sig ... endmodule Util_encode_decode : sig ... endmodule Util_io : sig ... endmodule Util_lwt : sig ... endmodule Util_lwt_seaboar : sig ... endmodule Util_pure : sig ... endmodule Util_yaml_io : sig ... endmodule Util_yaml : sig ... end