diff --git a/services/backup/src/constants.rs b/services/backup/src/constants.rs --- a/services/backup/src/constants.rs +++ b/services/backup/src/constants.rs @@ -4,32 +4,6 @@ pub const ID_SEPARATOR: &str = ":"; pub const ATTACHMENT_HOLDER_SEPARATOR: &str = ";"; -// 400KiB limit (in docs there is KB but they mean KiB) - -// https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ServiceQuotas.html -// This includes both attribute names' and values' lengths -// -// This has to be smaller than GRPC_CHUNK_SIZE_LIMIT because we need to -// recognize if we may receive multiple chunks or just one. If it was larger -// than the chunk limit, once we get the amount of data of size equal to the -// limit, we wouldn't know if we should put this in the database right away or -// wait for more data. -pub const LOG_DATA_SIZE_DATABASE_LIMIT: usize = 1024 * 400; - -// 4MB limit -// WARNING: use keeping in mind that grpc adds its own headers to messages -// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md -// so the message that actually is being sent over the network looks like this -// [Compressed-Flag] [Message-Length] [Message] -// [Compressed-Flag] 1 byte - added by grpc -// [Message-Length] 4 bytes - added by grpc -// [Message] N bytes - actual data -// so for every message we get 5 additional bytes of data -// as mentioned here -// https://github.com/grpc/grpc/issues/15734#issuecomment-396962671 -// grpc stream may contain more than one message -pub const GRPC_CHUNK_SIZE_LIMIT: usize = 4 * 1024 * 1024; -pub const GRPC_METADATA_SIZE_PER_MESSAGE: usize = 5; - // Configuration defaults pub const DEFAULT_BLOB_SERVICE_URL: &str = "http://localhost:50053"; diff --git a/services/comm-services-lib/src/constants.rs b/services/comm-services-lib/src/constants.rs new file mode 100644 --- /dev/null +++ b/services/comm-services-lib/src/constants.rs @@ -0,0 +1,19 @@ +// 400KiB limit (in docs there is KB but they mean KiB) - +// https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ServiceQuotas.html +// This includes both attribute names' and values' lengths +pub const DDB_ITEM_SIZE_LIMIT: usize = 1024 * 400; + +// 4MB limit +// WARNING: use keeping in mind that grpc adds its own headers to messages +// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md +// so the message that actually is being sent over the network looks like this +// [Compressed-Flag] [Message-Length] [Message] +// [Compressed-Flag] 1 byte - added by grpc +// [Message-Length] 4 bytes - added by grpc +// [Message] N bytes - actual data +// so for every message we get 5 additional bytes of data +// as mentioned here +// https://github.com/grpc/grpc/issues/15734#issuecomment-396962671 +// grpc stream may contain more than one message +pub const GRPC_CHUNK_SIZE_LIMIT: usize = 4 * 1024 * 1024; +pub const GRPC_METADATA_SIZE_PER_MESSAGE: usize = 5; diff --git a/services/comm-services-lib/src/lib.rs b/services/comm-services-lib/src/lib.rs --- a/services/comm-services-lib/src/lib.rs +++ b/services/comm-services-lib/src/lib.rs @@ -1,4 +1,5 @@ pub mod blob; +pub mod constants; pub mod database; #[cfg(feature = "http")] pub mod http;