Its a protocol for loro-crdt, that abstrats the client-server comunication logic, it provides a tool set to allow you to create sync servers for the loro-crdt.
Guitite, is a custom designed protocol by @feraxhp in @glifox. Its aim is to provide a small, simple and fast library to sync various loro-crdt clients
It is important to know that guitite, by default. does not mannage the loroDoc data persistance, it just mannage the comunication between peers.
Güitite (Acnistus arborescens) is a fruit-bearing tree nicknamed "loro's delight" because its sweet orange berries are a vital food source. (loro is a parrot).
The guitite::Server is the orchestrator for the conections it
keeps track of the opened "files" and the clients conected to them.
The Server exposes 2 methods to instanciate the server
- new: will create the simplest server. it contains a simple relay to demostrate sincronization with no persistance
- new_with_actor: this one allows to create a custom actor that implements the Protocol, Actor, and the Handlers for Connect, Message, Disconnect.
Create a simple relay server
use actix::{Actor, Addr};
use actix_web::{App, Error, HttpRequest, HttpResponse, HttpServer, get, web};
use actix_web_actors::ws;
use guitite::{Client, Server};
use env_logger;
#[get("/ws/{file_name}")]
async fn client(
req: HttpRequest,
stream: web::Payload,
srv: web::Data<Addr<Server>>,
path: web::Path<String>
) -> Result<HttpResponse, Error> {
log::info!("Try open {path}");
ws::start( Client::new(path.as_str(), srv.get_ref().clone()), &req, stream, )
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
env_logger::init();
let server = Server::new().start();
log::info!("starting HTTP server at http://localhost:8080");
HttpServer::new(move || {
App::new()
.app_data(web::Data::new(server.clone()))
.service(client)
})
.workers(2)
.bind(("127.0.0.1", 8080))?
.run()
.await
}