Set worker count 0 in debug mode

This commit is contained in:
Felix Ableitner 2022-06-03 12:37:57 +02:00
parent 58c9ea12ad
commit d7e401eeed
3 changed files with 12 additions and 11 deletions

View file

@ -39,10 +39,7 @@ pub struct Instance {
impl Instance {
pub fn new(hostname: String) -> Result<InstanceHandle, Error> {
let settings = InstanceSettingsBuilder::default()
.debug(true)
.worker_count(1)
.build()?;
let settings = InstanceSettingsBuilder::default().debug(true).build()?;
let local_instance =
LocalInstance::new(hostname.clone(), Client::default().into(), settings);
let local_user = MyUser::new(generate_object_id(&hostname)?, generate_actor_keypair()?);

View file

@ -2,6 +2,7 @@ use crate::{
core::signatures::{sign_request, PublicKey},
utils::verify_url_valid,
Error,
InstanceSettings,
LocalInstance,
APUB_JSON_CONTENT_TYPE,
};
@ -181,9 +182,16 @@ fn generate_request_headers(inbox_url: &Url) -> HeaderMap {
pub(crate) fn create_activity_queue(
client: ClientWithMiddleware,
worker_count: u64,
timeout: Duration,
settings: &InstanceSettings,
) -> Manager {
// queue is not used in debug mod, so dont create any workers to avoid log spam
let worker_count = if settings.debug {
0
} else {
settings.worker_count
};
let timeout = settings.request_timeout;
// Configure and start our workers
WorkerConfig::new_managed(Storage::new(), move |_| MyState {
client: client.clone(),

View file

@ -51,11 +51,7 @@ pub struct InstanceSettings {
impl LocalInstance {
pub fn new(domain: String, client: ClientWithMiddleware, settings: InstanceSettings) -> Self {
let activity_queue = create_activity_queue(
client.clone(),
settings.worker_count,
settings.request_timeout,
);
let activity_queue = create_activity_queue(client.clone(), &settings);
LocalInstance {
hostname: domain,
client,