Skip to content

Commit

Permalink
wip: remove legacy connection modules
Browse files Browse the repository at this point in the history
  • Loading branch information
cilki committed Jul 24, 2024
1 parent d8064e8 commit db1d58c
Show file tree
Hide file tree
Showing 10 changed files with 313 additions and 406 deletions.
305 changes: 225 additions & 80 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions sandpolis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ repository = "https:/fossable/sandpolis"
rust-version = "1.74"
version = "0.0.1"

[build-dependencies]
built = { version = "0.7", features = ["cargo-lock", "dependency-tree", "git2", "chrono", "semver"] }

[dependencies]
anyhow = "1.0.76"
clap = { version = "4.4.7", features = ["derive", "string"] }
Expand Down
10 changes: 10 additions & 0 deletions sandpolis/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use std::{env, path::PathBuf};

fn main() {
if built::write_built_file().is_err() {
let dest =
std::path::Path::new(&env::var("OUT_DIR").expect("OUT_DIR not set")).join("built.rs");
built::write_built_file_with_opts(Some(&PathBuf::from("..")), &dest)
.expect("Failed to acquire build-time information");
}
}
129 changes: 0 additions & 129 deletions sandpolis/src/agent/connection.rs

This file was deleted.

11 changes: 0 additions & 11 deletions sandpolis/src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,8 @@
//! The probe may attempt a spontaneous connection outside of the regular schedule
//! at any time.

pub mod connection;

use anyhow::{bail, Result};
use clap::Parser;
use predicates::{prelude::*, Predicate};
use std::collections::HashMap;
use std::io::BufRead;
use std::net::TcpStream;
Expand Down Expand Up @@ -274,11 +271,3 @@ fn connection_routine(config: &AgentConfig_LoopConfig) {
thread::sleep(time::Duration::from_millis(config.cooldown as u64));
}
}

fn dispatch_routine(connection: &mut Connection) {
debug!("Starting command dispatch routine");

loop {
// TODO
}
}
7 changes: 0 additions & 7 deletions sandpolis/src/client/ui/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@ pub struct Node {
pub id: NodeId,
pub collier: Collider,
pub rigid_body: RigidBody,
// /// User indication of whether an entity is visible
pub visibility: Visibility,
pub sprite: SpriteBundle,
// // Inherited visibility of an entity.
// pub inherited_visibility: InheritedVisibility,
pub restitution: Restitution,
// // Indication of whether an entity is visible in any view.
// pub view_visibility: ViewVisibility,
}

pub fn spawn_node(
Expand All @@ -38,7 +32,6 @@ pub fn spawn_node(
rigid_body: RigidBody::Dynamic,
// visibility: todo!(),
restitution: Restitution::coefficient(0.7),
visibility: Visibility::Visible,
sprite: SpriteBundle {
texture: asset_server.load(get_os_image(os_type)),
..default()
Expand Down
129 changes: 0 additions & 129 deletions sandpolis/src/connection.rs

This file was deleted.

44 changes: 43 additions & 1 deletion sandpolis/src/core/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,31 @@ pub struct LocalMetadata {
pub os_info: os_info::Info,
}

#[derive(Serialize, Deserialize, Clone, Debug)]
pub enum ReplicationAuth {
#[serde(rename = "basic")]
Basic { username: String, password: String },
}

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct ReplicationTarget {
pub url: String,
pub auth: ReplicationAuth,
}

#[derive(Serialize, Deserialize, Clone, Debug, CouchDocument)]
pub struct ReplicationTask {
#[serde(skip_serializing_if = "String::is_empty")]
pub _id: DocumentId,
#[serde(skip_serializing_if = "String::is_empty")]
pub _rev: String,

pub source: String,
pub target: ReplicationTarget,
pub create_target: bool,
pub continuous: bool,
}

#[derive(Clone)]
pub struct Database {
address: String,
Expand Down Expand Up @@ -158,7 +183,24 @@ impl Database {
.await?;

// Setup replications
// TODO
client
.db("_replicator")
.await?
.save(&mut ReplicationTask {
_id: "servers".into(),
_rev: "".into(),
source: "http://127.0.0.1:80/servers".into(),
target: ReplicationTarget {
url: "http://127.0.0.1:5984/servers".into(),
auth: ReplicationAuth::Basic {
username: "test".into(),
password: "test".into(),
},
},
create_target: true,
continuous: true,
})
.await?;

debug!(server_id = ?metadata.id, "Connected to server successfully");

Expand Down
Loading

0 comments on commit db1d58c

Please sign in to comment.