feat: move core to tui and begin grpc work
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
86cba91b16
commit
4a0fcd1bbb
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -1068,17 +1068,13 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"axum 0.7.5",
|
"axum 0.7.5",
|
||||||
"bus",
|
|
||||||
"clap",
|
"clap",
|
||||||
"dirs",
|
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"similar-asserts",
|
"similar-asserts",
|
||||||
"sqlx",
|
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower-http",
|
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"uuid",
|
"uuid",
|
||||||
@ -1118,15 +1114,19 @@ name = "hyperlog-tui"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"bus",
|
||||||
"crossterm",
|
"crossterm",
|
||||||
"directories",
|
"directories",
|
||||||
|
"dirs",
|
||||||
"human-panic",
|
"human-panic",
|
||||||
"hyperlog-core",
|
"hyperlog-core",
|
||||||
"itertools",
|
"itertools",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
"ropey",
|
"ropey",
|
||||||
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"similar-asserts",
|
"similar-asserts",
|
||||||
|
"tempfile",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
@ -13,18 +13,8 @@ dotenv.workspace = true
|
|||||||
axum.workspace = true
|
axum.workspace = true
|
||||||
|
|
||||||
serde = { version = "1.0.201", features = ["derive"] }
|
serde = { version = "1.0.201", features = ["derive"] }
|
||||||
sqlx = { version = "0.7.4", features = [
|
|
||||||
"runtime-tokio",
|
|
||||||
"tls-rustls",
|
|
||||||
"postgres",
|
|
||||||
"uuid",
|
|
||||||
"time",
|
|
||||||
] }
|
|
||||||
uuid = { version = "1.8.0", features = ["v4"] }
|
uuid = { version = "1.8.0", features = ["v4"] }
|
||||||
tower-http = { version = "0.5.2", features = ["cors", "trace"] }
|
|
||||||
serde_json = "1.0.117"
|
serde_json = "1.0.117"
|
||||||
bus = "2.4.1"
|
|
||||||
dirs = "5.0.1"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
similar-asserts = "1.5.0"
|
similar-asserts = "1.5.0"
|
||||||
|
@ -1,11 +1 @@
|
|||||||
#![feature(map_try_insert)]
|
|
||||||
|
|
||||||
pub mod commander;
|
|
||||||
pub mod querier;
|
|
||||||
|
|
||||||
pub mod engine;
|
|
||||||
pub mod events;
|
|
||||||
pub mod log;
|
pub mod log;
|
||||||
pub mod shared_engine;
|
|
||||||
pub mod state;
|
|
||||||
pub mod storage;
|
|
||||||
|
@ -3,14 +3,45 @@ syntax = "proto3";
|
|||||||
package hyperlog;
|
package hyperlog;
|
||||||
|
|
||||||
service Graph {
|
service Graph {
|
||||||
rpc SayHello (HelloRequest) returns (HelloReply);
|
rpc Get(GetRequest) returns (GetReply);
|
||||||
}
|
}
|
||||||
|
|
||||||
message HelloRequest {
|
|
||||||
string name = 1;
|
message UserGraphItem {
|
||||||
|
map<string, GraphItem> items = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
message SectionGraphItem {
|
||||||
|
map<string, GraphItem> items = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message HelloReply {
|
enum ItemState {
|
||||||
string message = 1;
|
UNSPECIFIED = 0;
|
||||||
|
NOT_DONE = 1;
|
||||||
|
DONE = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ItemGraphItem {
|
||||||
|
string title = 1;
|
||||||
|
string description = 2;
|
||||||
|
ItemState state = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GraphItem {
|
||||||
|
string path = 1;
|
||||||
|
oneof contents {
|
||||||
|
UserGraphItem user = 2;
|
||||||
|
SectionGraphItem section = 3;
|
||||||
|
ItemGraphItem item = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetRequest {
|
||||||
|
string root = 1;
|
||||||
|
repeated string paths = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetReply {
|
||||||
|
repeated GraphItem items = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
97
crates/hyperlog-server/src/commands.rs
Normal file
97
crates/hyperlog-server/src/commands.rs
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
use hyperlog_core::log::{GraphItem, ItemState};
|
||||||
|
|
||||||
|
pub enum Command {
|
||||||
|
CreateRoot {
|
||||||
|
root: String,
|
||||||
|
},
|
||||||
|
CreateSection {
|
||||||
|
root: String,
|
||||||
|
path: Vec<String>,
|
||||||
|
},
|
||||||
|
CreateItem {
|
||||||
|
root: String,
|
||||||
|
path: Vec<String>,
|
||||||
|
title: String,
|
||||||
|
description: String,
|
||||||
|
state: ItemState,
|
||||||
|
},
|
||||||
|
UpdateItem {
|
||||||
|
root: String,
|
||||||
|
path: Vec<String>,
|
||||||
|
title: String,
|
||||||
|
description: String,
|
||||||
|
state: ItemState,
|
||||||
|
},
|
||||||
|
ToggleItem {
|
||||||
|
root: String,
|
||||||
|
path: Vec<String>,
|
||||||
|
},
|
||||||
|
Move {
|
||||||
|
root: String,
|
||||||
|
src: Vec<String>,
|
||||||
|
dest: Vec<String>,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Commander {}
|
||||||
|
|
||||||
|
impl Commander {
|
||||||
|
pub fn execute(&self, cmd: Command) -> anyhow::Result<()> {
|
||||||
|
match cmd {
|
||||||
|
Command::CreateRoot { root } => todo!(),
|
||||||
|
Command::CreateSection { root, path } => todo!(),
|
||||||
|
Command::CreateItem {
|
||||||
|
root,
|
||||||
|
path,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
state,
|
||||||
|
} => todo!(),
|
||||||
|
Command::UpdateItem {
|
||||||
|
root,
|
||||||
|
path,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
state,
|
||||||
|
} => todo!(),
|
||||||
|
Command::ToggleItem { root, path } => todo!(),
|
||||||
|
Command::Move { root, src, dest } => todo!(),
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn create_root(&self, root: &str) -> anyhow::Result<()> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn create(&self, root: &str, path: &[&str], item: GraphItem) -> anyhow::Result<()> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get(&self, root: &str, path: &[&str]) -> Option<GraphItem> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn section_move(
|
||||||
|
&self,
|
||||||
|
root: &str,
|
||||||
|
src_path: &[&str],
|
||||||
|
dest_path: &[&str],
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn delete(&self, root: &str, path: &[&str]) -> anyhow::Result<()> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_item(
|
||||||
|
&self,
|
||||||
|
root: &str,
|
||||||
|
path: &[&str],
|
||||||
|
item: &GraphItem,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
82
crates/hyperlog-server/src/external_grpc.rs
Normal file
82
crates/hyperlog-server/src/external_grpc.rs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
use std::{collections::HashMap, net::SocketAddr};
|
||||||
|
|
||||||
|
use hyperlog_protos::hyperlog::{
|
||||||
|
graph_server::{Graph, GraphServer},
|
||||||
|
*,
|
||||||
|
};
|
||||||
|
use tonic::{transport, Response};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
querier::{Querier, QuerierExt},
|
||||||
|
state::SharedState,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct Server {
|
||||||
|
querier: Querier,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Server {
|
||||||
|
pub fn new(querier: Querier) -> Self {
|
||||||
|
Self { querier }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tonic::async_trait]
|
||||||
|
impl Graph for Server {
|
||||||
|
async fn get(
|
||||||
|
&self,
|
||||||
|
request: tonic::Request<GetRequest>,
|
||||||
|
) -> std::result::Result<tonic::Response<GetReply>, tonic::Status> {
|
||||||
|
let msg = request.get_ref();
|
||||||
|
|
||||||
|
tracing::trace!("get: req({:?})", msg);
|
||||||
|
|
||||||
|
Ok(Response::new(GetReply {
|
||||||
|
items: vec![
|
||||||
|
GraphItem {
|
||||||
|
path: "some.path".into(),
|
||||||
|
contents: Some(graph_item::Contents::Item(ItemGraphItem {
|
||||||
|
title: "some-title".into(),
|
||||||
|
description: "some-description".into(),
|
||||||
|
state: ItemState::NotDone as i32,
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
GraphItem {
|
||||||
|
path: "some.path.section".into(),
|
||||||
|
contents: Some(graph_item::Contents::Section(SectionGraphItem {
|
||||||
|
items: HashMap::new(),
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
GraphItem {
|
||||||
|
path: "some.path".into(),
|
||||||
|
contents: Some(graph_item::Contents::User(UserGraphItem {
|
||||||
|
items: HashMap::new(),
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait ServerExt {
|
||||||
|
fn grpc_server(&self) -> Server;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ServerExt for SharedState {
|
||||||
|
fn grpc_server(&self) -> Server {
|
||||||
|
Server::new(self.querier())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn serve(state: &SharedState, host: SocketAddr) -> anyhow::Result<()> {
|
||||||
|
tracing::info!("listening on {}", host);
|
||||||
|
|
||||||
|
let graph_server = state.grpc_server();
|
||||||
|
|
||||||
|
transport::Server::builder()
|
||||||
|
.add_service(GraphServer::new(graph_server))
|
||||||
|
.serve(host)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
@ -2,49 +2,13 @@ use std::{net::SocketAddr, sync::Arc};
|
|||||||
|
|
||||||
use crate::state::{SharedState, State};
|
use crate::state::{SharedState, State};
|
||||||
|
|
||||||
|
mod external_grpc;
|
||||||
mod external_http;
|
mod external_http;
|
||||||
mod internal_http;
|
mod internal_http;
|
||||||
mod external_grpc {
|
|
||||||
use std::net::SocketAddr;
|
|
||||||
|
|
||||||
use hyperlog_protos::hyperlog::{
|
mod commands;
|
||||||
graph_server::{Graph, GraphServer},
|
mod querier;
|
||||||
HelloReply, HelloRequest,
|
|
||||||
};
|
|
||||||
use tonic::{transport, Response};
|
|
||||||
|
|
||||||
use crate::state::SharedState;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
struct Server {}
|
|
||||||
|
|
||||||
#[tonic::async_trait]
|
|
||||||
impl Graph for Server {
|
|
||||||
async fn say_hello(
|
|
||||||
&self,
|
|
||||||
request: tonic::Request<HelloRequest>,
|
|
||||||
) -> std::result::Result<tonic::Response<HelloReply>, tonic::Status> {
|
|
||||||
tracing::info!("received hello request");
|
|
||||||
|
|
||||||
Ok(Response::new(HelloReply {
|
|
||||||
message: "hello".into(),
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn serve(state: &SharedState, host: SocketAddr) -> anyhow::Result<()> {
|
|
||||||
tracing::info!("listening on {}", host);
|
|
||||||
|
|
||||||
let graph_server = Server::default();
|
|
||||||
|
|
||||||
transport::Server::builder()
|
|
||||||
.add_service(GraphServer::new(graph_server))
|
|
||||||
.serve(host)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mod state;
|
mod state;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
33
crates/hyperlog-server/src/querier.rs
Normal file
33
crates/hyperlog-server/src/querier.rs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
use hyperlog_core::log::GraphItem;
|
||||||
|
|
||||||
|
use crate::state::SharedState;
|
||||||
|
|
||||||
|
pub struct Querier {}
|
||||||
|
|
||||||
|
impl Querier {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_available_roots(&self) -> Option<Vec<String>> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get(
|
||||||
|
&self,
|
||||||
|
root: &str,
|
||||||
|
path: impl IntoIterator<Item = impl Into<String>>,
|
||||||
|
) -> Option<GraphItem> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait QuerierExt {
|
||||||
|
fn querier(&self) -> Querier;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl QuerierExt for SharedState {
|
||||||
|
fn querier(&self) -> Querier {
|
||||||
|
Querier::new()
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,7 @@ anyhow.workspace = true
|
|||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
tracing-subscriber.workspace = true
|
tracing-subscriber.workspace = true
|
||||||
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
|
|
||||||
@ -19,6 +20,9 @@ crossterm = { version = "0.27.0", features = ["event-stream"] }
|
|||||||
directories = "5.0.1"
|
directories = "5.0.1"
|
||||||
human-panic = "2.0.0"
|
human-panic = "2.0.0"
|
||||||
ropey = "1.6.1"
|
ropey = "1.6.1"
|
||||||
|
bus = "2.4.1"
|
||||||
|
dirs = "5.0.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
similar-asserts = "1.5.0"
|
similar-asserts = "1.5.0"
|
||||||
|
tempfile = "3.10.1"
|
||||||
|
@ -5,7 +5,7 @@ use ratatui::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
command_parser::CommandParser, commands::IntoCommand,
|
command_parser::CommandParser, commander, commands::IntoCommand,
|
||||||
components::graph_explorer::GraphExplorer, state::SharedState, Msg,
|
components::graph_explorer::GraphExplorer, state::SharedState, Msg,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ pub enum Dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Dialog {
|
impl Dialog {
|
||||||
pub fn get_command(&self) -> Option<hyperlog_core::commander::Command> {
|
pub fn get_command(&self) -> Option<commander::Command> {
|
||||||
match self {
|
match self {
|
||||||
Dialog::CreateItem { state } => state.get_command(),
|
Dialog::CreateItem { state } => state.get_command(),
|
||||||
Dialog::EditItem { state } => state.get_command(),
|
Dialog::EditItem { state } => state.get_command(),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use ratatui::{prelude::*, widgets::*};
|
use ratatui::{prelude::*, widgets::*};
|
||||||
|
|
||||||
use crate::models::Msg;
|
use crate::{commander, models::Msg};
|
||||||
|
|
||||||
use super::{InputBuffer, InputField};
|
use super::{InputBuffer, InputField};
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ impl CreateItemState {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_command(&self) -> Option<hyperlog_core::commander::Command> {
|
pub fn get_command(&self) -> Option<commander::Command> {
|
||||||
let title = self.title.string();
|
let title = self.title.string();
|
||||||
let description = self.description.string();
|
let description = self.description.string();
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ impl CreateItemState {
|
|||||||
let mut path = self.path.clone();
|
let mut path = self.path.clone();
|
||||||
path.push(title.replace([' ', '.'], "-"));
|
path.push(title.replace([' ', '.'], "-"));
|
||||||
|
|
||||||
Some(hyperlog_core::commander::Command::CreateItem {
|
Some(commander::Command::CreateItem {
|
||||||
root: self.root.clone(),
|
root: self.root.clone(),
|
||||||
path,
|
path,
|
||||||
title: title.trim().into(),
|
title: title.trim().into(),
|
||||||
|
@ -2,7 +2,7 @@ use hyperlog_core::log::GraphItem;
|
|||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use ratatui::{prelude::*, widgets::*};
|
use ratatui::{prelude::*, widgets::*};
|
||||||
|
|
||||||
use crate::models::Msg;
|
use crate::{commander, models::Msg};
|
||||||
|
|
||||||
use super::{InputBuffer, InputField};
|
use super::{InputBuffer, InputField};
|
||||||
|
|
||||||
@ -82,14 +82,14 @@ impl EditItemState {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_command(&self) -> Option<hyperlog_core::commander::Command> {
|
pub fn get_command(&self) -> Option<commander::Command> {
|
||||||
let title = self.title.string();
|
let title = self.title.string();
|
||||||
let description = self.description.string();
|
let description = self.description.string();
|
||||||
|
|
||||||
if !title.is_empty() {
|
if !title.is_empty() {
|
||||||
let path = self.path.clone();
|
let path = self.path.clone();
|
||||||
|
|
||||||
Some(hyperlog_core::commander::Command::UpdateItem {
|
Some(commander::Command::UpdateItem {
|
||||||
root: self.root.clone(),
|
root: self.root.clone(),
|
||||||
path,
|
path,
|
||||||
title: title.trim().into(),
|
title: title.trim().into(),
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
use hyperlog_core::log::{GraphItem, ItemState};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{events::Events, shared_engine::SharedEngine, storage::Storage};
|
||||||
events::Events,
|
|
||||||
log::{GraphItem, ItemState},
|
|
||||||
shared_engine::SharedEngine,
|
|
||||||
storage::Storage,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Serialize, PartialEq, Eq, Debug, Clone)]
|
#[derive(Serialize, PartialEq, Eq, Debug, Clone)]
|
||||||
pub enum Command {
|
pub enum Command {
|
@ -3,7 +3,7 @@ use hyperlog_core::log::GraphItem;
|
|||||||
use ratatui::{prelude::*, widgets::*};
|
use ratatui::{prelude::*, widgets::*};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
command_parser::Commands, components::movement_graph::GraphItemType, models::Msg,
|
command_parser::Commands, commander, components::movement_graph::GraphItemType, models::Msg,
|
||||||
state::SharedState,
|
state::SharedState,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -196,12 +196,12 @@ impl<'a> GraphExplorer<'a> {
|
|||||||
let mut path = self.get_current_path();
|
let mut path = self.get_current_path();
|
||||||
path.push(name.replace(" ", "-").replace(".", "-"));
|
path.push(name.replace(" ", "-").replace(".", "-"));
|
||||||
|
|
||||||
self.state.commander.execute(
|
self.state
|
||||||
hyperlog_core::commander::Command::CreateSection {
|
.commander
|
||||||
|
.execute(commander::Command::CreateSection {
|
||||||
root: self.inner.root.clone(),
|
root: self.inner.root.clone(),
|
||||||
path,
|
path,
|
||||||
},
|
})?;
|
||||||
)?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Commands::Edit => {
|
Commands::Edit => {
|
||||||
@ -247,7 +247,7 @@ impl<'a> GraphExplorer<'a> {
|
|||||||
|
|
||||||
self.state
|
self.state
|
||||||
.commander
|
.commander
|
||||||
.execute(hyperlog_core::commander::Command::ToggleItem {
|
.execute(commander::Command::ToggleItem {
|
||||||
root: self.inner.root.to_string(),
|
root: self.inner.root.to_string(),
|
||||||
path: self.get_current_path(),
|
path: self.get_current_path(),
|
||||||
})?;
|
})?;
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use std::{collections::BTreeMap, fmt::Display};
|
use std::{collections::BTreeMap, fmt::Display};
|
||||||
|
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
|
use hyperlog_core::log::{Graph, GraphItem, ItemState};
|
||||||
use crate::log::{Graph, GraphItem, ItemState};
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Engine {
|
pub struct Engine {
|
||||||
@ -218,10 +217,9 @@ impl Display for Engine {
|
|||||||
mod test {
|
mod test {
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
use hyperlog_core::log::{GraphItem, ItemState};
|
||||||
use similar_asserts::assert_eq;
|
use similar_asserts::assert_eq;
|
||||||
|
|
||||||
use crate::log::{GraphItem, ItemState};
|
|
||||||
|
|
||||||
use super::Engine;
|
use super::Engine;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -249,7 +247,7 @@ mod test {
|
|||||||
.create(
|
.create(
|
||||||
"kjuulh",
|
"kjuulh",
|
||||||
&["some-section"],
|
&["some-section"],
|
||||||
crate::log::GraphItem::Section(BTreeMap::default()),
|
GraphItem::Section(BTreeMap::default()),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -275,7 +273,7 @@ mod test {
|
|||||||
.create(
|
.create(
|
||||||
"kjuulh",
|
"kjuulh",
|
||||||
&["some-section"],
|
&["some-section"],
|
||||||
crate::log::GraphItem::Section(BTreeMap::default()),
|
GraphItem::Section(BTreeMap::default()),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -283,7 +281,7 @@ mod test {
|
|||||||
.create(
|
.create(
|
||||||
"kjuulh",
|
"kjuulh",
|
||||||
&["some-section", "some-sub-section"],
|
&["some-section", "some-sub-section"],
|
||||||
crate::log::GraphItem::Section(BTreeMap::default()),
|
GraphItem::Section(BTreeMap::default()),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
|
#![feature(map_try_insert)]
|
||||||
#![feature(fn_traits)]
|
#![feature(fn_traits)]
|
||||||
|
|
||||||
use std::{io::Stdout, time::Duration};
|
use std::{io::Stdout, time::Duration};
|
||||||
@ -6,8 +7,8 @@ use anyhow::{Context, Result};
|
|||||||
use app::{render_app, App};
|
use app::{render_app, App};
|
||||||
use commands::IntoCommand;
|
use commands::IntoCommand;
|
||||||
use components::graph_explorer::GraphExplorer;
|
use components::graph_explorer::GraphExplorer;
|
||||||
|
use core_state::State;
|
||||||
use crossterm::event::{self, Event, KeyCode};
|
use crossterm::event::{self, Event, KeyCode};
|
||||||
use hyperlog_core::state::State;
|
|
||||||
use models::{EditMsg, Msg};
|
use models::{EditMsg, Msg};
|
||||||
use ratatui::{backend::CrosstermBackend, Terminal};
|
use ratatui::{backend::CrosstermBackend, Terminal};
|
||||||
|
|
||||||
@ -19,7 +20,16 @@ pub(crate) mod app;
|
|||||||
pub(crate) mod command_parser;
|
pub(crate) mod command_parser;
|
||||||
pub(crate) mod commands;
|
pub(crate) mod commands;
|
||||||
pub(crate) mod components;
|
pub(crate) mod components;
|
||||||
pub(crate) mod state;
|
|
||||||
|
pub mod commander;
|
||||||
|
pub mod core_state;
|
||||||
|
pub mod shared_engine;
|
||||||
|
pub mod state;
|
||||||
|
|
||||||
|
mod engine;
|
||||||
|
mod events;
|
||||||
|
mod querier;
|
||||||
|
mod storage;
|
||||||
|
|
||||||
mod logging;
|
mod logging;
|
||||||
mod terminal;
|
mod terminal;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
use crate::{log::GraphItem, shared_engine::SharedEngine};
|
use hyperlog_core::log::GraphItem;
|
||||||
|
|
||||||
|
use crate::shared_engine::SharedEngine;
|
||||||
|
|
||||||
pub struct Querier {
|
pub struct Querier {
|
||||||
engine: SharedEngine,
|
engine: SharedEngine,
|
@ -1,6 +1,8 @@
|
|||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
|
|
||||||
use crate::{engine::Engine, log::GraphItem};
|
use hyperlog_core::log::GraphItem;
|
||||||
|
|
||||||
|
use crate::engine::Engine;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct SharedEngine {
|
pub struct SharedEngine {
|
@ -1,6 +1,6 @@
|
|||||||
use std::{ops::Deref, sync::Arc};
|
use std::{ops::Deref, sync::Arc};
|
||||||
|
|
||||||
use hyperlog_core::state::State;
|
use crate::core_state::State;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct SharedState {
|
pub struct SharedState {
|
||||||
|
@ -149,10 +149,9 @@ impl Storage {
|
|||||||
mod test {
|
mod test {
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
use hyperlog_core::log::GraphItem;
|
||||||
use similar_asserts::assert_eq;
|
use similar_asserts::assert_eq;
|
||||||
|
|
||||||
use crate::log::GraphItem;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
@ -1,7 +1,7 @@
|
|||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use hyperlog_core::{commander, state};
|
use hyperlog_tui::{commander, core_state::State, state};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
@ -90,7 +90,7 @@ pub async fn execute() -> anyhow::Result<()> {
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
Some(Commands::Exec { commands }) => {
|
Some(Commands::Exec { commands }) => {
|
||||||
let state = state::State::new()?;
|
let state = State::new()?;
|
||||||
match commands {
|
match commands {
|
||||||
ExecCommands::CreateRoot { root } => state
|
ExecCommands::CreateRoot { root } => state
|
||||||
.commander
|
.commander
|
||||||
@ -109,7 +109,7 @@ pub async fn execute() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Commands::Query { commands }) => {
|
Some(Commands::Query { commands }) => {
|
||||||
let state = state::State::new()?;
|
let state = State::new()?;
|
||||||
match commands {
|
match commands {
|
||||||
QueryCommands::Get { root, path } => {
|
QueryCommands::Get { root, path } => {
|
||||||
let res = state.querier.get(
|
let res = state.querier.get(
|
||||||
@ -126,23 +126,23 @@ pub async fn execute() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Commands::CreateRoot { name }) => {
|
Some(Commands::CreateRoot { name }) => {
|
||||||
let state = state::State::new()?;
|
let state = State::new()?;
|
||||||
state
|
state
|
||||||
.commander
|
.commander
|
||||||
.execute(commander::Command::CreateRoot { root: name })?;
|
.execute(commander::Command::CreateRoot { root: name })?;
|
||||||
println!("Root was successfully created, now run:\n\n$ hyperlog");
|
println!("Root was successfully created, now run:\n\n$ hyperlog");
|
||||||
}
|
}
|
||||||
Some(Commands::Info {}) => {
|
Some(Commands::Info {}) => {
|
||||||
let state = state::State::new()?;
|
let state = State::new()?;
|
||||||
println!("graph stored at: {}", state.storage.info()?)
|
println!("graph stored at: {}", state.storage.info()?)
|
||||||
}
|
}
|
||||||
Some(Commands::ClearLock {}) => {
|
Some(Commands::ClearLock {}) => {
|
||||||
let state = state::State::new()?;
|
let state = State::new()?;
|
||||||
state.storage.clear_lock_file();
|
state.storage.clear_lock_file();
|
||||||
println!("cleared lock file");
|
println!("cleared lock file");
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let state = state::State::new()?;
|
let state = State::new()?;
|
||||||
hyperlog_tui::execute(state).await?;
|
hyperlog_tui::execute(state).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,4 +12,4 @@ tear_down() {
|
|||||||
|
|
||||||
trap tear_down SIGINT
|
trap tear_down SIGINT
|
||||||
|
|
||||||
RUST_LOG=info,hyperlog=trace cargo run -F include_server -- serve
|
RUST_LOG=info,hyperlog=trace cargo watch -x 'run -F include_server -- serve'
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
version: "3"
|
|
||||||
services:
|
services:
|
||||||
crdb:
|
crdb:
|
||||||
restart: 'always'
|
restart: 'always'
|
||||||
@ -11,5 +10,5 @@ services:
|
|||||||
retries: 5
|
retries: 5
|
||||||
start_period: '20s'
|
start_period: '20s'
|
||||||
ports:
|
ports:
|
||||||
- 8080:8080
|
- 28080:8080
|
||||||
- '26257:26257'
|
- '26257:26257'
|
||||||
|
Loading…
Reference in New Issue
Block a user