Compare commits
1 commit
7b64e300b6
...
89975894a4
Author | SHA1 | Date | |
---|---|---|---|
89975894a4 |
6 changed files with 24 additions and 13 deletions
|
@ -13,8 +13,12 @@ impl Handler<FileUpdated> for ServerActor {
|
|||
|
||||
fn handle(&mut self, _msg: FileUpdated, ctx: &mut Self::Context) -> Self::Result {
|
||||
match ServerConfig::load(&self.fs) {
|
||||
Ok(server_config) => self.do_send(ReceiveServerConfig::new(server_config), ctx),
|
||||
Err(err) => self.abort(ctx, format!("Failed to load config file. Error: {}", err)),
|
||||
Ok(server_config) => {
|
||||
self.do_send(ReceiveServerConfig::new(server_config), ctx);
|
||||
}
|
||||
Err(err) => {
|
||||
self.abort(ctx, format!("Failed to load config file. Error: {}", err));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,15 +12,15 @@ impl Handler<ReceiveServerConfig> for ServerActor {
|
|||
fn handle(&mut self, msg: ReceiveServerConfig, ctx: &mut Self::Context) -> Self::Result {
|
||||
tracing::info!("recieved server config");
|
||||
let Ok(socket_addr) = msg.http() else {
|
||||
return self.abort(ctx, "Unable to parse http.addr");
|
||||
self.abort(ctx, "Unable to parse http.addr");
|
||||
};
|
||||
|
||||
let Some(server_storage) = self.server_storage(&msg) else {
|
||||
return self.abort(ctx, "Server storage not available");
|
||||
self.abort(ctx, "Server storage not available");
|
||||
};
|
||||
|
||||
if msg.inbound_webhook().base_url().ends_with('/') {
|
||||
return self.abort(ctx, "webhook.url must not end with a '/'");
|
||||
self.abort(ctx, "webhook.url must not end with a '/'");
|
||||
}
|
||||
|
||||
self.do_send(
|
||||
|
|
|
@ -229,11 +229,17 @@ impl ServerActor {
|
|||
Some(server_storage)
|
||||
}
|
||||
|
||||
/// Attempts to gracefully shutdown the server before stopping the system.
|
||||
fn abort(&mut self, ctx: &mut <Self as actix::Actor>::Context, message: impl Into<String>) {
|
||||
/// Attempts to gracefully shutdown the server before terminating the process.
|
||||
fn abort(
|
||||
&mut self,
|
||||
ctx: &mut <Self as actix::Actor>::Context,
|
||||
message: impl Into<String>,
|
||||
) -> ! {
|
||||
tracing::error!("Aborting: {}", message.into());
|
||||
self.do_send(crate::server::actor::messages::Shutdown, ctx);
|
||||
System::current().stop_with_code(1);
|
||||
std::thread::sleep(std::time::Duration::from_millis(200));
|
||||
System::current().stop();
|
||||
std::process::exit(-1);
|
||||
}
|
||||
|
||||
fn do_send<M>(&mut self, msg: M, _ctx: &mut <Self as actix::Actor>::Context)
|
||||
|
|
|
@ -52,5 +52,5 @@ async fn when_webhook_url_has_trailing_slash_should_not_send() {
|
|||
tracing::debug!(?message_log, "");
|
||||
assert!(message_log.read().iter().any(|log| !log
|
||||
.iter()
|
||||
.any(|line| line == "send: ReceiveValidServerConfig")));
|
||||
.any(|line| line != "send: ReceiveValidServerConfig")));
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ impl super::OpenRepositoryLike for RealOpenRepository {
|
|||
) -> Result<Vec<git::Commit>, git::commit::log::Error> {
|
||||
let limit = match find_commits.is_empty() {
|
||||
true => 1,
|
||||
false => 25,
|
||||
false => 50,
|
||||
};
|
||||
self.0
|
||||
.read()
|
||||
|
|
|
@ -19,17 +19,18 @@ fn should_return_single_item_in_commit_log_when_not_searching() -> TestResult {
|
|||
|
||||
#[test]
|
||||
// assumes running in the git-next repo which should have main, next and dev as remote branches
|
||||
fn should_return_capacity_25_in_commit_log_when_searching_for_garbage() -> TestResult {
|
||||
fn should_return_capacity_50_in_commit_log_when_searching_for_garbage() -> TestResult {
|
||||
let_assert!(Ok(fs) = kxio::fs::temp());
|
||||
let branch_name = given::a_branch_name();
|
||||
let gitdir = GitDir::new(fs.base().to_path_buf(), StoragePathType::Internal);
|
||||
let test_repository = git::repository::test(fs.clone());
|
||||
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
|
||||
for _ in [0; 25] {
|
||||
for _ in [0; 60] {
|
||||
// create 60 commits
|
||||
then::create_a_commit_on_branch(&fs, &gitdir, &branch_name)?;
|
||||
}
|
||||
let_assert!(Ok(result) = open_repository.commit_log(&branch_name, &[given::a_commit()]));
|
||||
assert_eq!(result.len(), 25);
|
||||
assert_eq!(result.len(), 50);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue