mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-12-22 11:21:24 +00:00
Allow configuring console buffer capacity
This commit is contained in:
parent
bd26c60cd5
commit
62615be371
6 changed files with 44 additions and 15 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1580,7 +1580,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pict-rs"
|
||||
version = "0.3.0-rc.5"
|
||||
version = "0.3.0-rc.6"
|
||||
dependencies = [
|
||||
"actix-form-data",
|
||||
"actix-rt",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "pict-rs"
|
||||
description = "A simple image hosting service"
|
||||
version = "0.3.0-rc.5"
|
||||
version = "0.3.0-rc.6"
|
||||
authors = ["asonix <asonix@asonix.dog>"]
|
||||
license = "AGPL-3.0"
|
||||
readme = "README.md"
|
||||
|
|
27
README.md
27
README.md
|
@ -9,7 +9,7 @@ _a simple image hosting service_
|
|||
## Usage
|
||||
### Running
|
||||
```
|
||||
pict-rs 0.3.0-rc.5
|
||||
pict-rs 0.3.0-rc.6
|
||||
|
||||
USAGE:
|
||||
pict-rs [FLAGS] [OPTIONS] [SUBCOMMAND]
|
||||
|
@ -20,27 +20,34 @@ FLAGS:
|
|||
-V, --version Prints version information
|
||||
|
||||
OPTIONS:
|
||||
-a, --addr <addr> The address and port the server binds to.
|
||||
-a, --addr <addr> The address and port the server binds to.
|
||||
--api-key <api-key>
|
||||
An optional string to be checked on requests to privileged endpoints
|
||||
|
||||
-c, --config-file <config-file> Path to the pict-rs configuration file
|
||||
-c, --config-file <config-file> Path to the pict-rs configuration file
|
||||
--console-buffer-capacity <console-buffer-capacity>
|
||||
Specify the number of events the console subscriber is allowed to buffer
|
||||
|
||||
-f, --filters <filters>...
|
||||
An optional list of filters to permit, supports 'identity', 'thumbnail', 'resize', 'crop', and 'blur'
|
||||
|
||||
-i, --image-format <image-format>
|
||||
An optional image format to convert all uploaded files into, supports 'jpg', 'png', and 'webp'
|
||||
|
||||
-m, --max-file-size <max-file-size> Specify the maximum allowed uploaded file size (in Megabytes)
|
||||
--max-image-area <max-image-area> Specify the maximum area in pixels allowed in an image
|
||||
--max-image-height <max-image-height> Specify the maximum width in pixels allowed on an image
|
||||
--max-image-width <max-image-width> Specify the maximum width in pixels allowed on an image
|
||||
--migrate-file <migrate-file> Path to a file defining a store migration
|
||||
-m, --max-file-size <max-file-size>
|
||||
Specify the maximum allowed uploaded file size (in Megabytes)
|
||||
|
||||
--max-image-area <max-image-area> Specify the maximum area in pixels allowed in an image
|
||||
--max-image-height <max-image-height> Specify the maximum width in pixels allowed on an image
|
||||
--max-image-width <max-image-width> Specify the maximum width in pixels allowed on an image
|
||||
--migrate-file <migrate-file> Path to a file defining a store migration
|
||||
-o, --opentelemetry-url <opentelemetry-url>
|
||||
Enable OpenTelemetry Tracing exports to the given OpenTelemetry collector
|
||||
|
||||
-p, --path <path> The path to the data directory, e.g. data/
|
||||
--sled-cache-capacity <sled-cache-capacity> Specify the number of bytes sled is allowed to use for it's cache
|
||||
-p, --path <path> The path to the data directory, e.g. data/
|
||||
--sled-cache-capacity <sled-cache-capacity>
|
||||
Specify the number of bytes sled is allowed to use for it's cache
|
||||
|
||||
|
||||
SUBCOMMANDS:
|
||||
file-store
|
||||
|
|
|
@ -82,6 +82,13 @@ pub(crate) struct Overrides {
|
|||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
sled_cache_capacity: Option<u64>,
|
||||
|
||||
#[structopt(
|
||||
long,
|
||||
help = "Specify the number of events the console subscriber is allowed to buffer"
|
||||
)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
console_buffer_capacity: Option<usize>,
|
||||
|
||||
#[structopt(
|
||||
long,
|
||||
help = "An optional string to be checked on requests to privileged endpoints"
|
||||
|
@ -114,6 +121,7 @@ impl Overrides {
|
|||
&& self.max_image_height.is_none()
|
||||
&& self.max_image_area.is_none()
|
||||
&& self.sled_cache_capacity.is_none()
|
||||
&& self.console_buffer_capacity.is_none()
|
||||
&& self.api_key.is_none()
|
||||
&& self.opentelemetry_url.is_none()
|
||||
&& self.store.is_none()
|
||||
|
@ -192,6 +200,7 @@ pub(crate) struct Config {
|
|||
max_image_height: usize,
|
||||
max_image_area: usize,
|
||||
sled_cache_capacity: u64,
|
||||
console_buffer_capacity: usize,
|
||||
api_key: Option<String>,
|
||||
opentelemetry_url: Option<Url>,
|
||||
store: Store,
|
||||
|
@ -207,6 +216,7 @@ pub(crate) struct Defaults {
|
|||
max_image_height: usize,
|
||||
max_image_area: usize,
|
||||
sled_cache_capacity: u64,
|
||||
console_buffer_capacity: usize,
|
||||
store: Store,
|
||||
}
|
||||
|
||||
|
@ -220,6 +230,7 @@ impl Defaults {
|
|||
max_image_height: 10_000,
|
||||
max_image_area: 40_000_000,
|
||||
sled_cache_capacity: 1024 * 1024 * 64, // 16 times smaller than sled's default of 1GB
|
||||
console_buffer_capacity: 1024 * 128,
|
||||
store: Store::FileStore { path: None },
|
||||
}
|
||||
}
|
||||
|
@ -275,6 +286,11 @@ impl Config {
|
|||
self.sled_cache_capacity
|
||||
}
|
||||
|
||||
#[cfg(feature = "console")]
|
||||
pub(crate) fn console_buffer_capacity(&self) -> usize {
|
||||
self.console_buffer_capacity
|
||||
}
|
||||
|
||||
pub(crate) fn format(&self) -> Option<Format> {
|
||||
self.image_format
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ use url::Url;
|
|||
pub(super) fn init_tracing(
|
||||
servic_name: &'static str,
|
||||
opentelemetry_url: Option<&Url>,
|
||||
#[cfg(feature = "console")] buffer_capacity: usize,
|
||||
) -> anyhow::Result<()> {
|
||||
LogTracer::init()?;
|
||||
|
||||
|
@ -32,7 +33,7 @@ pub(super) fn init_tracing(
|
|||
#[cfg(feature = "console")]
|
||||
let console_layer = ConsoleLayer::builder()
|
||||
.with_default_env()
|
||||
.event_buffer_capacity(1024 * 1024)
|
||||
.event_buffer_capacity(buffer_capacity)
|
||||
.server_addr(([0, 0, 0, 0], 6669))
|
||||
.spawn();
|
||||
|
||||
|
|
|
@ -882,7 +882,12 @@ where
|
|||
|
||||
#[actix_rt::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
init_tracing("pict-rs", CONFIG.opentelemetry_url())?;
|
||||
init_tracing(
|
||||
"pict-rs",
|
||||
CONFIG.opentelemetry_url(),
|
||||
#[cfg(feature = "console")]
|
||||
CONFIG.console_buffer_capacity(),
|
||||
)?;
|
||||
|
||||
let db = LatestDb::exists(CONFIG.data_dir(), CONFIG.sled_cache_capacity()).migrate()?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue