Crates.io | flmodules |
lib.rs | flmodules |
version | 0.8.0 |
source | src |
created_at | 2022-07-05 18:29:41.096864 |
updated_at | 2024-09-09 12:00:20.299137 |
description | Modules used in fledger |
homepage | https://fledg.re |
repository | https://github.com/ineiti/fledger |
max_upload_size | |
id | 619950 |
size | 223,433 |
This crate holds the raw modules for Fledger. They are written in a way to be as reusable as possible. For this, most modules have the following structure:
broker.rs
- which contains the code to interact with the other modulesmodule.rs
- with the main code of the module, with at least a process_msg
method
that inputs a message and outputs a vector of answersdata-structures
- implementing the basic functionality of the module.Currently the following modules are available:
timer
sends out one message per second and one message per minuterandom_connections
takes a list of nodes and randomly selects enough nodes for
a fully connected networkping
uses random_connections
to send regular messages to the connected nodes
to make sure they answer. If a node doesn't answer in due time, a failure message
is emitted.gossip_events
exchanges events emitted by the nodes and updates the list. It
works both in active mode - sending new messages to neighbours - as in passive
mode - requesting list of available events from other nodes.network
is the basic networking code to set up a new connection using
the signalling server.web_proxy
allows sending a http GET request to another node, using the other
node as a proxy.As described in the previous section, you should write your modules in three parts:
Translator
which takes incoming messages
and outputs messges defined in the Message Handling
file.I wanted to create a common code for both the libc- and wasm-implementation for
Fledger.
Unfortunately it is difficult by the fact that libc allows to use threads
(and sometimes needs them), so some structures need to have the Send
and Sync
traits.
But these traits are not available for all necessary websys-modules!
So I came up with the idea of linking all modules using a Broker
system.
In short, all input and output for a module are defined as messages.
Then each module handles incoming messages and produces outgoing messages.
Modules can be linked together by defining Translators
that take messages
from one module and translate them into messages for the other module.