generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 39
feat(casi): implement core IO and logging functionality #567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jmt-lab
wants to merge
1
commit into
bottlerocket-os:project/cas
Choose a base branch
from
jmt-lab:cas/stage-1
base: project/cas
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| [package] | ||
| name = "casi" | ||
| version = "0.1.0" | ||
| authors = ["Jarrett Tierney <[email protected]>"] | ||
| license = "Apache-2.0 OR MIT" | ||
| edition = "2021" | ||
| publish = false | ||
|
|
||
| [dependencies] | ||
| astral-tokio-tar.workspace = true | ||
| async-compression = { workspace = true, features = ["tokio", "zstd"] } | ||
| async-trait.workspace = true | ||
| aws-config.workspace = true | ||
| aws-sdk-s3.workspace = true | ||
| aws-smithy-types.workspace = true | ||
| aws-types.workspace = true | ||
| bon.workspace = true | ||
| chrono = { workspace = true, features = ["serde", "now"] } | ||
| clap = { workspace = true, features = ["derive"] } | ||
| futures.workspace = true | ||
| hex.workspace = true | ||
| indicatif.workspace = true | ||
| oci-spec.workspace = true | ||
| olpc-cjson.workspace = true | ||
| owo-colors = { workspace = true, features = ["supports-colors"] } | ||
| parking_lot = { workspace = true, features = ["send_guard", "arc_lock"] } | ||
| rand.workspace = true | ||
| semver = { workspace = true, features = ["serde"] } | ||
| serde = { workspace = true, features = ["derive"] } | ||
| serde_json.workspace = true | ||
| sha2.workspace = true | ||
| snafu.workspace = true | ||
| tempfile.workspace = true | ||
| tokio = { workspace = true, features = ["full"] } | ||
| tracing.workspace = true | ||
| tracing-indicatif.workspace = true | ||
| tracing-subscriber = { workspace = true, features = [ | ||
| "env-filter", | ||
| "fmt", | ||
| "registry", | ||
| ] } | ||
| url = { workspace = true, features = ["serde"] } | ||
| uuid = { workspace = true, features = ["v4"] } | ||
| walkdir.workspace = true | ||
| zstd.workspace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| //! Constants used throughout the casi crate. | ||
| //! | ||
| //! This module centralizes magic numbers and commonly used values to improve | ||
| //! code maintainability and reduce the likelihood of errors. | ||
|
|
||
| /// Default buffer size for I/O operations (64KB) | ||
| pub const DEFAULT_BUFFER_SIZE: usize = 64 * 1024; | ||
|
|
||
| /// Buffer size for hashing operations (128MB) | ||
| /// Uses 8KB chunks which align with standard memory page sizes for optimal | ||
| /// performance when reading from files and network streams. | ||
| pub const HASH_BUFFER_SIZE: usize = 128 * 1024 * 1024; | ||
|
|
||
| /// Maximum number of multipart upload parts for S3 | ||
| pub const MAX_MULTIPART_PARTS: usize = 10_000; | ||
|
|
||
| /// Minimum size for S3 multipart upload parts (5MB) | ||
| pub const MIN_MULTIPART_PART_SIZE: usize = 5 * 1024 * 1024; | ||
|
|
||
| /// Default compression level for Zstd | ||
| pub const DEFAULT_COMPRESSION_LEVEL: i32 = 3; | ||
|
|
||
| /// Maximum file name length for cross-platform compatibility | ||
| pub const MAX_FILENAME_LENGTH: usize = 255; | ||
|
|
||
| /// Default timeout for network operations (30 seconds) | ||
| pub const DEFAULT_NETWORK_TIMEOUT_SECS: u64 = 30; | ||
|
|
||
| /// Maximum retry attempts for transient failures | ||
| pub const MAX_RETRY_ATTEMPTS: usize = 3; | ||
|
|
||
| /// Default page size for listing operations | ||
| pub const DEFAULT_PAGE_SIZE: usize = 100; | ||
|
|
||
| /// Maximum artifacts to display in table format | ||
| pub const MAX_TABLE_DISPLAY_ARTIFACTS: usize = 1000; | ||
|
|
||
| /// Hash truncation length for display purposes | ||
| pub const HASH_DISPLAY_LENGTH: usize = 16; | ||
|
|
||
| /// Schema version for OCI manifests | ||
| pub const OCI_MANIFEST_SCHEMA_VERSION: u32 = 2; | ||
|
|
||
| /// Default file permissions for created files (0o644) | ||
| pub const DEFAULT_FILE_PERMISSIONS: u32 = 0o644; | ||
|
|
||
| /// Default directory permissions for created directories (0o755) | ||
| pub const DEFAULT_DIR_PERMISSIONS: u32 = 0o755; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| use snafu::Snafu; | ||
|
|
||
| pub type Result<T> = std::result::Result<T, Error>; | ||
|
|
||
| #[derive(Debug, Snafu)] | ||
| #[snafu(visibility(pub))] | ||
| pub enum Error { | ||
| #[snafu(display( | ||
| "Failed to read data for hashing: {source} - check if the file exists and is readable" | ||
| ))] | ||
| HashingReadError { source: std::io::Error }, | ||
|
|
||
| #[snafu(display("Failed to initialize logging system: {source}"))] | ||
| LogInit { | ||
| source: Box<dyn std::error::Error + Send + Sync>, | ||
| }, | ||
|
|
||
| #[snafu(display("Failed to parse log directive: {directive}"))] | ||
| LogDirectiveParse { directive: String }, | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect you will be like O.O about this tokio tar and the async-compression crate below. The astral-tokio-tar is the currently maintaing tokio tar crate variant which provides us to use streaming tar readers for archives. async-compression likewise creates bufread and writer wrappers over zstd