Add --bench-script cli arg
This commit is contained in:
parent
e03617edda
commit
f84a5b288e
5 changed files with 42 additions and 23 deletions
|
|
@ -6,14 +6,11 @@
|
|||
mod queue;
|
||||
mod repo;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use gix::ThreadSafeRepository;
|
||||
use tracing::{debug_span, error, Instrument};
|
||||
|
||||
use super::Server;
|
||||
use super::{BenchRepo, Repo, Server};
|
||||
|
||||
async fn recurring_task(state: &Server, repo: Arc<ThreadSafeRepository>) {
|
||||
async fn recurring_task(state: &Server, repo: Repo) {
|
||||
async {
|
||||
if let Err(e) = repo::update(&state.db, repo).await {
|
||||
error!("Error updating repo:\n{e:?}");
|
||||
|
|
@ -31,7 +28,7 @@ async fn recurring_task(state: &Server, repo: Arc<ThreadSafeRepository>) {
|
|||
.await;
|
||||
}
|
||||
|
||||
pub async fn run(server: Server, repo: Arc<ThreadSafeRepository>) {
|
||||
pub(super) async fn run(server: Server, repo: Repo, bench_repo: Option<BenchRepo>) {
|
||||
loop {
|
||||
recurring_task(&server, repo.clone()).await;
|
||||
tokio::time::sleep(server.config.repo_update_delay).await;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
//! Add new commits to the database and update the tracked refs.
|
||||
|
||||
use std::{collections::HashSet, sync::Arc};
|
||||
use std::collections::HashSet;
|
||||
|
||||
use futures::TryStreamExt;
|
||||
use gix::{
|
||||
objs::Kind, prelude::ObjectIdExt, refs::Reference, ObjectId, Repository, ThreadSafeRepository,
|
||||
};
|
||||
use gix::{objs::Kind, prelude::ObjectIdExt, refs::Reference, ObjectId, Repository};
|
||||
use sqlx::{Acquire, SqliteConnection, SqlitePool};
|
||||
use tracing::{debug, info};
|
||||
|
||||
use crate::{server::util, somehow};
|
||||
use crate::{
|
||||
server::{util, Repo},
|
||||
somehow,
|
||||
};
|
||||
|
||||
async fn get_all_commit_hashes_from_db(
|
||||
conn: &mut SqliteConnection,
|
||||
|
|
@ -227,9 +228,9 @@ async fn update_commit_tracked_status(conn: &mut SqliteConnection) -> somehow::R
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn update(db: &SqlitePool, repo: Arc<ThreadSafeRepository>) -> somehow::Result<()> {
|
||||
pub(super) async fn update(db: &SqlitePool, repo: Repo) -> somehow::Result<()> {
|
||||
debug!("Updating repo");
|
||||
let thread_local_repo = repo.to_thread_local();
|
||||
let thread_local_repo = repo.0.to_thread_local();
|
||||
let mut tx = db.begin().await?;
|
||||
let conn = tx.acquire().await?;
|
||||
|
||||
|
|
@ -244,7 +245,7 @@ pub async fn update(db: &SqlitePool, repo: Arc<ThreadSafeRepository>) -> somehow
|
|||
// This can take a while for larger repos. Running it via spawn_blocking
|
||||
// keeps it from blocking the entire tokio worker.
|
||||
let (refs, new) = tokio::task::spawn_blocking(move || {
|
||||
get_all_refs_and_new_commits_from_repo(&repo.to_thread_local(), &old)
|
||||
get_all_refs_and_new_commits_from_repo(&repo.0.to_thread_local(), &old)
|
||||
})
|
||||
.await??;
|
||||
debug!("Found {} new commits in repo", new.len());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue