- Added a diagram explaining the architecture of the OurDB syncer, clarifying the interaction between the HTTP server, master, and worker nodes. - Added a README file providing a comprehensive overview of the OurDB syncer project, including its architecture, features, prerequisites, installation instructions, and usage examples. - Removed outdated Mycelium_Streamer documentation as it's no longer relevant to the current project structure. - Created example scripts for running the database, master, and worker components, simplifying the setup and execution of the system. - Added HTTP client and server documentation, clarifying their functionalities and interaction with the OurDB system.
51 lines
1.6 KiB
Verilog
51 lines
1.6 KiB
Verilog
module server
|
|
|
|
// import net.http
|
|
// import rand
|
|
|
|
// struct App {
|
|
// master_addr string // Mycelium address of master
|
|
// worker_addrs []string // Mycelium addresses of workers
|
|
// }
|
|
|
|
// fn (app App) handle_set(w http.ResponseWriter, r http.Request) {
|
|
// // Parse key-value from request
|
|
// key := r.form['key'] or { return w.write_string('Missing key') }
|
|
// value := r.form['value'] or { return w.write_string('Missing value') }
|
|
|
|
// // Forward SET request to master via Mycelium
|
|
// response := send_to_mycelium(app.master_addr, 'SET', key, value)
|
|
// w.write_string(response)
|
|
// }
|
|
|
|
// fn (app App) handle_get(w http.Response, r http.Request) {
|
|
// // Parse key from request
|
|
// key := r.data
|
|
|
|
// // Select a random worker to handle GET
|
|
// worker_addr := app.worker_addrs[rand.intn(app.worker_addrs.len) or { 0 }]
|
|
// // response := send_to_mycelium(worker_addr, 'GET', key, '')
|
|
// // w.write_string(response)
|
|
// }
|
|
|
|
// fn (app App) handle_delete(w http.ResponseWriter, r http.Request) {
|
|
// // Parse key from request
|
|
// key := r.form['key'] or { return w.write_string('Missing key') }
|
|
|
|
// // Forward DELETE request to master via Mycelium
|
|
// response := send_to_mycelium(app.master_addr, 'DELETE', key, '')
|
|
// w.write_string(response)
|
|
// }
|
|
|
|
// fn main() {
|
|
// app := App{
|
|
// master_addr: 'mycelium://master_node_address'
|
|
// worker_addrs: ['mycelium://worker1_address', 'mycelium://worker2_address']
|
|
// }
|
|
// mut server := http.new_server('0.0.0.0:8080')
|
|
// server.handle('/set', app.handle_set)
|
|
// server.handle('/get', app.handle_get)
|
|
// server.handle('/delete', app.handle_delete)
|
|
// server.listen_and_serve()
|
|
// }
|