• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 5829059745

pending completion
5829059745

Pull #1844

github

supergi01
added comments for downloader.rs
Pull Request #1844: feat/live-reload, download and start react server

735 of 735 new or added lines in 11 files covered. (100.0%)

45536 of 61287 relevant lines covered (74.3%)

51206.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/dozer-cache/src/main.rs
1
use std::pin::pin;
2

3
use clap::{Parser, Subcommand};
4
use dozer_cache::cache::{
5
    begin_dump_txn, dump, expression::QueryExpression, CacheManagerOptions, LmdbRoCacheManager,
6
    LmdbRwCacheManager, RoCache,
7
};
8
use dozer_storage::generator::{Generator, IntoGenerator};
9
use dozer_types::labels::Labels;
10
use tokio::io::AsyncWriteExt;
11

12
#[derive(Debug, Parser)]
×
13
struct Cli {
14
    /// Dozer cache directory.
15
    cache_dir: String,
×
16
    /// The endpoint name.
17
    endpoint: String,
×
18
    /// The build name.
19
    build: String,
×
20
    #[clap(subcommand)]
21
    command: CacheCommand,
22
}
23

24
#[derive(Debug, Subcommand)]
×
25
enum CacheCommand {
26
    /// Counts the number of records in the cache.
27
    Count,
28
    /// Dumps the cache to a file.
29
    Dump {
30
        /// The path to the file to dump to.
31
        path: String,
×
32
    },
33
    /// Restores the cache from a file.
34
    Restore {
35
        /// The path to the file to restore from.
36
        path: String,
×
37
    },
38
}
39

40
#[tokio::main]
41
async fn main() {
×
42
    env_logger::init();
×
43

×
44
    let cli = Cli::parse();
×
45
    let labels = labels(cli.endpoint.clone(), cli.build.clone());
×
46

×
47
    match cli.command {
×
48
        CacheCommand::Count => {
×
49
            let cache_manager = LmdbRoCacheManager::new(CacheManagerOptions {
×
50
                path: Some(cli.cache_dir.into()),
×
51
                ..Default::default()
×
52
            })
×
53
            .unwrap();
×
54
            let cache = cache_manager.open_lmdb_cache(labels).unwrap().unwrap();
×
55
            let count = cache.count(&QueryExpression::with_no_limit()).unwrap();
×
56
            println!("Count: {}", count);
×
57
        }
×
58
        CacheCommand::Dump { path } => {
×
59
            let cache_manager = LmdbRoCacheManager::new(CacheManagerOptions {
×
60
                path: Some(cli.cache_dir.into()),
×
61
                ..Default::default()
×
62
            })
×
63
            .unwrap();
×
64
            let cache = &cache_manager.open_lmdb_cache(labels).unwrap().unwrap();
×
65
            let file = tokio::fs::File::create(path).await.unwrap();
×
66
            let mut writer = tokio::io::BufWriter::new(file);
×
67

×
68
            let txn = &begin_dump_txn(cache).unwrap();
×
69
            let generator = |context| async move { dump(cache, txn, &context).await.unwrap() };
×
70
            let generator = generator.into_generator();
×
71
            for item in pin!(generator).into_iter() {
×
72
                let item = item.unwrap();
×
73
                writer.write_all(&item).await.unwrap();
×
74
            }
75

76
            writer.flush().await.unwrap();
×
77
        }
78
        CacheCommand::Restore { path } => {
×
79
            let cache_manager = LmdbRwCacheManager::new(CacheManagerOptions {
×
80
                path: Some(cli.cache_dir.into()),
×
81
                ..Default::default()
×
82
            })
×
83
            .unwrap();
×
84
            let file = tokio::fs::File::open(path).await.unwrap();
×
85
            let mut reader = tokio::io::BufReader::new(file);
×
86
            cache_manager
×
87
                .restore_cache(labels, Default::default(), &mut reader)
×
88
                .await
×
89
                .unwrap();
×
90
        }
91
    }
92
}
93

94
fn labels(endpoint: String, build: String) -> Labels {
×
95
    let mut labels = Labels::default();
×
96
    labels.push("endpoint", endpoint);
×
97
    labels.push("build", build);
×
98
    labels
×
99
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc