wheeee
parent
7a23fba2ae
commit
56d5f59daf
|
|
@ -2,6 +2,387 @@
|
|||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell_polyfill",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.49"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gethostname"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"
|
||||
dependencies = [
|
||||
"rustix",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.177"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell_polyfill"
|
||||
version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.103"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pttodoest"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"gethostname",
|
||||
"serde",
|
||||
"serde_yaml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_yaml"
|
||||
version = "0.9.34+deprecated"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
"unsafe-libyaml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.110"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
||||
|
||||
[[package]]
|
||||
name = "unsafe-libyaml"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.60.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.53.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.53.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
|
||||
|
|
|
|||
|
|
@ -4,3 +4,7 @@ version = "0.1.0"
|
|||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.51", features = ["derive"] }
|
||||
gethostname = "1.1.0"
|
||||
serde = { version = "1.0.228", features = ["serde_derive"] }
|
||||
serde_yaml = "0.9.34"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,263 @@
|
|||
use clap::Parser;
|
||||
use serde_yaml;
|
||||
use std::io::Read;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
for file in Flags::new()
|
||||
.expect("failed to flags")
|
||||
.files()
|
||||
.expect("failed to files")
|
||||
.files
|
||||
.iter()
|
||||
{
|
||||
file.reconcile_snapshot_changes().unwrap();
|
||||
println!(
|
||||
"{} => {:?}",
|
||||
file.file,
|
||||
file.events().unwrap().snapshot().unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
struct Flags {
|
||||
#[arg(short = 'f', long = "path", default_value = "$PTTODO_FILE")]
|
||||
path: String,
|
||||
|
||||
#[arg(short = 'a', long = "add")]
|
||||
add: Option<String>,
|
||||
|
||||
#[arg(short = 'e', long = "edit", default_value = "false")]
|
||||
edit: bool,
|
||||
|
||||
#[arg(short = 'd', long = "dry-run", default_value = "false")]
|
||||
dry_run: bool,
|
||||
}
|
||||
|
||||
impl Flags {
|
||||
fn new() -> Result<Flags, String> {
|
||||
let mut result = Flags::parse();
|
||||
|
||||
if result.path.get(..1) == Some("$") {
|
||||
result.path = match std::env::var(result.path.get(1..).unwrap()) {
|
||||
Ok(v) => Ok(v),
|
||||
Err(msg) => Err(format!("'{}' unset: {}", result.path, msg)),
|
||||
}?;
|
||||
}
|
||||
|
||||
let _ = result.files()?;
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn files(&self) -> Result<Files, String> {
|
||||
let metadata = match std::fs::metadata(self.path.clone()) {
|
||||
Ok(v) => Ok(v),
|
||||
Err(msg) => Err(format!("failed to load {}: {}", self.path.clone(), msg)),
|
||||
}?;
|
||||
let files = match metadata.is_dir() {
|
||||
false => Ok(vec![self.path.clone()]),
|
||||
true => match std::fs::read_dir(self.path.clone()) {
|
||||
Ok(paths) => Ok(paths
|
||||
.filter(|x| x.is_ok())
|
||||
.map(|x| x.unwrap())
|
||||
.filter(|x| x.metadata().unwrap().is_file())
|
||||
// TODO filter out hidden files
|
||||
.map(|x| x.path().display().to_string())
|
||||
.collect()),
|
||||
Err(msg) => Err(format!("failed to read {}: {}", self.path.clone(), msg)),
|
||||
},
|
||||
}?;
|
||||
Ok(Files::new(&files))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct Files {
|
||||
files: Vec<File>,
|
||||
}
|
||||
|
||||
impl Files {
|
||||
fn new(files: &Vec<String>) -> Files {
|
||||
Files {
|
||||
files: files.into_iter().map(|x| File::new(x)).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct File {
|
||||
file: String,
|
||||
}
|
||||
|
||||
impl File {
|
||||
fn new(file: &String) -> File {
|
||||
File { file: file.clone() }
|
||||
}
|
||||
|
||||
fn events(&self) -> Result<Events, String> {
|
||||
Events::new(&self.file)
|
||||
}
|
||||
|
||||
fn reconcile_snapshot_changes(&self) -> Result<(), String> {
|
||||
let history = self.events()?.snapshot()?;
|
||||
let cached = self.snapshot()?;
|
||||
match history == cached {
|
||||
true => Ok(()),
|
||||
false => {
|
||||
for task in history.iter() {
|
||||
if !cached.contains(task) {
|
||||
self.pop(task.clone())?;
|
||||
}
|
||||
}
|
||||
for i in 0..cached.len() {
|
||||
if !history.contains(&cached[i]) {
|
||||
self.push(TaskAt {
|
||||
task: cached[i].clone(),
|
||||
at: i,
|
||||
})?;
|
||||
}
|
||||
}
|
||||
panic!("not impl")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn snapshot(&self) -> Result<Vec<Task>, String> {
|
||||
let mut r = match std::fs::File::open(self.file.clone()) {
|
||||
Ok(f) => Ok(f),
|
||||
Err(msg) => Err(format!("could not open {}: {}", &self.file, msg)),
|
||||
}?;
|
||||
|
||||
let mut buff = String::new();
|
||||
match r.read_to_string(&mut buff) {
|
||||
Err(msg) => Err(format!("failed reading {}: {}", &self.file, msg)),
|
||||
_ => Ok({}),
|
||||
}?;
|
||||
|
||||
let mut result = vec![];
|
||||
match serde_yaml::from_str::<Vec<serde_yaml::Value>>(&buff) {
|
||||
Ok(v) => {
|
||||
result.extend(v.iter().map(|x| Task(x.clone())));
|
||||
Ok({})
|
||||
}
|
||||
Err(msg) => Err(format!("failed parsing {}: {}", &self.file, msg)),
|
||||
}?;
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn push(&self, task_at: TaskAt) -> Result<(), String> {
|
||||
self.append(Delta {
|
||||
pushed_at: vec![task_at],
|
||||
popped: vec![],
|
||||
})
|
||||
}
|
||||
|
||||
fn pop(&self, task: Task) -> Result<(), String> {
|
||||
self.append(Delta {
|
||||
pushed_at: vec![],
|
||||
popped: vec![task],
|
||||
})
|
||||
}
|
||||
|
||||
fn append(&self, delta: Delta) -> Result<(), String> {
|
||||
use std::fs::OpenOptions;
|
||||
let hostname = gethostname::gethostname();
|
||||
let mut file = match OpenOptions::new().write(true).append(true).open(&self.file) {
|
||||
Ok(f) => Ok(f),
|
||||
Err(msg) => Err(format!(
|
||||
"failed to open {} for appending: {}",
|
||||
&self.file, msg
|
||||
)),
|
||||
}?;
|
||||
panic!("not impl: {:?}", file)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct Delta {
|
||||
pushed_at: Vec<TaskAt>,
|
||||
popped: Vec<Task>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct TaskAt {
|
||||
task: Task,
|
||||
at: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
struct Task(serde_yaml::Value);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct Events(Vec<Delta>);
|
||||
|
||||
impl Events {
|
||||
fn new(file: &String) -> Result<Events, String> {
|
||||
let logs = match std::fs::read_dir(Self::dir(&file)) {
|
||||
Ok(files) => Ok(files
|
||||
.filter(|x| x.is_ok())
|
||||
.map(|x| x.unwrap())
|
||||
.filter(|x| x.metadata().unwrap().is_file())
|
||||
.map(|x| x.path().display().to_string())
|
||||
.filter(|x| x.starts_with(&Self::log_prefix(&file)))
|
||||
.collect::<Vec<String>>()),
|
||||
Err(msg) => Err(format!("failed to read dir {}: {}", Self::dir(&file), msg)),
|
||||
}?;
|
||||
|
||||
let mut result = vec![];
|
||||
for log in logs.iter() {
|
||||
panic!("{:?}", log);
|
||||
}
|
||||
Ok(Events(result))
|
||||
}
|
||||
|
||||
fn log_prefix(file: &String) -> String {
|
||||
format!("{}/.{}.", Self::dir(&file), Self::basename(&file)).to_string()
|
||||
}
|
||||
|
||||
fn dir(file: &String) -> String {
|
||||
let path = std::path::Path::new(&file);
|
||||
path.parent()
|
||||
.expect("cannot get dirname")
|
||||
.to_str()
|
||||
.expect("cannot stringify dirname")
|
||||
.to_string()
|
||||
}
|
||||
|
||||
fn basename(file: &String) -> String {
|
||||
let path = std::path::Path::new(&file);
|
||||
path.file_name()
|
||||
.expect("cannot get basename")
|
||||
.to_str()
|
||||
.expect("cannot stringify basename")
|
||||
.to_string()
|
||||
}
|
||||
|
||||
fn snapshot(&self) -> Result<Vec<Task>, String> {
|
||||
let mut result = vec![];
|
||||
for event in self.0.iter() {
|
||||
for popped in event.popped.iter() {
|
||||
for i in (0..result.len())
|
||||
.map(|i| i as usize)
|
||||
.filter(|i| result[*i] == *popped)
|
||||
{
|
||||
panic!("not impl")
|
||||
}
|
||||
}
|
||||
for push in event.pushed_at.iter() {
|
||||
result.insert(
|
||||
if push.at < result.len() {
|
||||
push.at
|
||||
} else {
|
||||
result.len()
|
||||
},
|
||||
push.task.clone(),
|
||||
);
|
||||
}
|
||||
panic!("not impl: {:?}", result)
|
||||
}
|
||||
Ok(result)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
- read; https://topicpartition.io/blog/postgres-pubsub-queue-benchmarks
|
||||
- |
|
||||
pglogical vs ha
|
||||
|
||||
# api.git#breel/keys-620-pglogical-always-set-cr/2-user-survives-cr
|
||||
$ mise run pulsegres-new ^logical/toggl
|
||||
- drive; VERIFY spoc posts daily summary w/ unresolved
|
||||
- drive; VERIFY spoc refreshes summary w/ thread comment contianing 'refresh'
|
||||
- 637; reconcile deploy if replicas wrong; https://github.com/renderinc/api/pull/26540/files
|
||||
- https://linear.app/render-com/issue/KEYS-633/add-3-when-max-connections-overridden-for-3-superuser-connections
|
||||
- https://linear.app/render-com/issue/KEYS-637/billing-resume-should-1-unsuspend-pg-in-cloudsql-2-unsuspend-pg-in-cr
|
||||
- https://linear.app/render-com/issue/KEYS-638/pgoperator-generates-new-ha-patroni-cert-every-reconcile-no-matter
|
||||
- pg; how2partition; https://renderinc.slack.com/archives/C0319NYCSSG/p1756357545556659?thread_ts=1756357467.613369&cid=C0319NYCSSG
|
||||
- pitr; backup purge cronjob for PL types
|
||||
- pg11 pgbackup doesnt write to envsetting mucked env key
|
||||
- incident io; teach spocbotvr to read slacks
|
||||
- userdb to internal; peer packages can use internal as userdb
|
||||
- fcr; cannot pitr because pgbackrest doesnt know wal spans thus pgexporter and friends
|
||||
cant know pitr works
|
||||
- |
|
||||
etcd statefulset of 1 (for no random podname, no conflict, k8s ensures pod replace)
|
||||
patroni always
|
||||
- maher; https://slab.render.com/posts/hopes-and-dreams-blegf8fx#hdsyt-valkey-bundle
|
||||
- maher; shadow lizhi pm loops
|
||||
- maher; get more interviewers
|
||||
- maher; get concrete career and project plans so i can get promo in 2y; no manager
|
||||
to advocate
|
||||
- read; https://trychroma.com/engineering/wal3
|
||||
- read; https://github.com/renderinc/dashboard/pull/8883
|
||||
- read; https://litestream.io/getting-started/
|
||||
- |
|
||||
kr
|
||||
to del gcloud old key
|
||||
ie https://console.cloud.google.com/iam-admin/serviceaccounts/details/104206017956912104938/keys?hl=en&project=render-prod
|
||||
- todo: blocked
|
||||
subtasks:
|
||||
- ""
|
||||
- |
|
||||
pitr
|
||||
https://slab.render.com/posts/pitr-as-a-service-health-abvnqx11
|
||||
more aggressive alert autotune backup cores
|
||||
more aggressive alert on MOAR backup cores
|
||||
create alert autotune archive-push cores
|
||||
create alert MOAR archive-push cores
|
||||
- cr; frontend
|
||||
- cr; cli.git
|
||||
- cr; public-api-schema.git; https://github.com/renderinc/public-api-schema/pull/407
|
||||
STILL NEED EVENTS
|
||||
- cr; website.git
|
||||
- cr; changelog
|
||||
- ops; pgproxy rate limits 50ps 100burst; https://github.com/renderinc/dbproxy/pull/91
|
||||
- 2873; no conn patroni if upgradeInProgressWithoutHA; https://github.com/renderinc/api/pull/26328
|
||||
- 2733; only EnvSettings; https://github.com/renderinc/api/pull/25322/files
|
||||
- pg18; after cred rotation works, re enable e2e
|
||||
- 655; pg18; pub api sch; https://github.com/renderinc/public-api-schema/pull/421
|
||||
- 655; pg18; go generate pub api sch; https://github.com/renderinc/api/pull/26694
|
||||
- 663; das; show status in /info; https://github.com/renderinc/dashboard/pull/9616
|
||||
- 664; pg18; go gen terraform; https://github.com/renderinc/api/pull/26701
|
||||
- 664; pg18; ga; push terraform.git#breel/keys-664-pg18
|
||||
- 656; pg18; website; https://github.com/renderinc/website/pull/985/files
|
||||
- 663; das; note disk cannot decrease even if autoscaled; https://github.com/renderinc/dashboard/pull/9621
|
||||
- pulsegres; pls let me keep my test emails; https://github.com/renderinc/api/pull/26741
|
||||
- pgup; restore view owner; https://github.com/renderinc/api/pull/26814
|
||||
- pgup; resync if missing resync; https://github.com/renderinc/api/pull/26817
|
||||
- pgup; replicas use $RESYNC; https://github.com/renderinc/api/pull/26878
|
||||
Loading…
Reference in New Issue