Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Default for LoreVergen {
warning = revision_info.warning;
}

LoreVergen {
Self {
lore_library_version_name: format!("{package_version}+{lib_version}"),
warning,
}
Expand Down
6 changes: 3 additions & 3 deletions lore-aws/src/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub struct TaskQueueSettings {

impl Default for TaskQueueSettings {
fn default() -> Self {
TaskQueueSettings {
Self {
quota_per_second: default_quota_per_second(),
concurrency_limit: default_concurrency_limit(),
submission_limit: default_submission_limit(),
Expand Down Expand Up @@ -251,7 +251,7 @@ pub struct WantsTables {
}

impl AwsClientBuilder<WantsTables> {
pub fn ensure_table(mut self, table_name: impl Into<String>) -> AwsClientBuilder<WantsTables> {
pub fn ensure_table(mut self, table_name: impl Into<String>) -> Self {
self.0.tables.push(table_name.into());

self
Expand Down Expand Up @@ -294,7 +294,7 @@ pub struct WantsBuckets {
}

impl AwsClientBuilder<WantsBuckets> {
pub fn ensure_bucket(mut self, bucket: impl Into<String>) -> AwsClientBuilder<WantsBuckets> {
pub fn ensure_bucket(mut self, bucket: impl Into<String>) -> Self {
self.0.buckets.push(bucket.into());

self
Expand Down
24 changes: 12 additions & 12 deletions lore-aws/src/store/immutable_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct FragmentsEntry {

impl From<&FragmentsEntry> for Address {
fn from(value: &FragmentsEntry) -> Self {
Address {
Self {
hash: value.hash,
context: Context::from(&value.repository_context[size_of::<Context>()..]),
}
Expand Down Expand Up @@ -233,14 +233,14 @@ enum FragmentsQuery {
impl DynamoDbQuery for FragmentsQuery {
fn key_condition_expression(&self) -> &str {
match self {
FragmentsQuery::Repository(_, _) => "#pk = :hash and begins_with(#sk, :repository)",
FragmentsQuery::Hash(_) | FragmentsQuery::HashCount(_) => "#pk = :hash",
Self::Repository(_, _) => "#pk = :hash and begins_with(#sk, :repository)",
Self::Hash(_) | Self::HashCount(_) => "#pk = :hash",
}
}

fn expression_attribute_names(&self) -> HashMap<String, String> {
match self {
FragmentsQuery::Repository(_, _) => HashMap::from([
Self::Repository(_, _) => HashMap::from([
(
"#pk".to_string(),
FRAGMENTS_DYNAMO_PARTITION_KEY_ATTRIBUTE.to_string(),
Expand All @@ -250,7 +250,7 @@ impl DynamoDbQuery for FragmentsQuery {
FRAGMENTS_DYNAMO_SORT_KEY_ATTRIBUTE.to_string(),
),
]),
FragmentsQuery::Hash(_) | FragmentsQuery::HashCount(_) => HashMap::from([(
Self::Hash(_) | Self::HashCount(_) => HashMap::from([(
"#pk".to_string(),
FRAGMENTS_DYNAMO_PARTITION_KEY_ATTRIBUTE.to_string(),
)]),
Expand All @@ -259,7 +259,7 @@ impl DynamoDbQuery for FragmentsQuery {

fn expression_attribute_values(&self) -> HashMap<String, AttributeValue> {
match self {
FragmentsQuery::Repository(hash, repository) => HashMap::from([
Self::Repository(hash, repository) => HashMap::from([
(
":hash".to_string(),
AttributeValue::B(Blob::new(hash.data())),
Expand All @@ -269,7 +269,7 @@ impl DynamoDbQuery for FragmentsQuery {
AttributeValue::B(Blob::new(repository.data())),
),
]),
FragmentsQuery::Hash(hash) | FragmentsQuery::HashCount(hash) => HashMap::from([(
Self::Hash(hash) | Self::HashCount(hash) => HashMap::from([(
":hash".to_string(),
AttributeValue::B(Blob::new(hash.data())),
)]),
Expand All @@ -278,20 +278,20 @@ impl DynamoDbQuery for FragmentsQuery {

fn limit(&self) -> Option<i32> {
match self {
FragmentsQuery::Repository(_, _) | FragmentsQuery::Hash(_) => Some(1),
FragmentsQuery::HashCount(_) => None,
Self::Repository(_, _) | Self::Hash(_) => Some(1),
Self::HashCount(_) => None,
}
}

fn select(&self) -> Option<Select> {
match self {
FragmentsQuery::Repository(_, _) | FragmentsQuery::Hash(_) => None,
FragmentsQuery::HashCount(_) => Some(Select::Count),
Self::Repository(_, _) | Self::Hash(_) => None,
Self::HashCount(_) => Some(Select::Count),
}
}

fn consistent_read(&self) -> bool {
matches!(self, FragmentsQuery::HashCount(_))
matches!(self, Self::HashCount(_))
}
}

Expand Down
112 changes: 51 additions & 61 deletions lore-aws/src/store/lock_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,57 +139,49 @@ impl std::fmt::Debug for LockKey {
impl DynamoDbQuery for LockQuery {
fn index_name(&self) -> Option<String> {
match self {
LockQuery::Owner(_)
| LockQuery::OwnerRepository(_, _)
| LockQuery::OwnerRepositoryBranch(_, _, _) => Some(OWNER_REPO_BRANCH_GSI.to_string()),
LockQuery::Repository(_) | LockQuery::RepositoryBranch(_, _) => {
Some(REPO_BRANCH_GSI.to_string())
}
LockQuery::RepositoryBranchDescription(_, _, _) => {
Some(REPO_BRANCH_DESC_GSI.to_string())
Self::Owner(_) | Self::OwnerRepository(_, _) | Self::OwnerRepositoryBranch(_, _, _) => {
Some(OWNER_REPO_BRANCH_GSI.to_string())
}
Self::Repository(_) | Self::RepositoryBranch(_, _) => Some(REPO_BRANCH_GSI.to_string()),
Self::RepositoryBranchDescription(_, _, _) => Some(REPO_BRANCH_DESC_GSI.to_string()),
_ => None,
}
}

fn key_condition_expression(&self) -> &str {
match self {
LockQuery::Hash(_) => "#pk = :hash",
LockQuery::HashRepository(_, _) => "#pk = :hash and begins_with(#sk, :repo)",
LockQuery::HashRepositoryBranch(_, _, _) => "#pk = :hash and #sk = :repoBranch",
LockQuery::Owner(_) => "#pk = :owner",
LockQuery::OwnerRepository(_, _) => "#pk = :owner and begins_with(#sk, :repo)",
LockQuery::OwnerRepositoryBranch(_, _, _) => "#pk = :owner and #sk = :repoBranch",
LockQuery::Repository(_) => "#pk = :repo",
LockQuery::RepositoryBranch(_, _) => "#pk = :repo and #sk = :branch",
LockQuery::RepositoryBranchDescription(_, _, _) => {
Self::Hash(_) => "#pk = :hash",
Self::HashRepository(_, _) => "#pk = :hash and begins_with(#sk, :repo)",
Self::HashRepositoryBranch(_, _, _) => "#pk = :hash and #sk = :repoBranch",
Self::Owner(_) => "#pk = :owner",
Self::OwnerRepository(_, _) => "#pk = :owner and begins_with(#sk, :repo)",
Self::OwnerRepositoryBranch(_, _, _) => "#pk = :owner and #sk = :repoBranch",
Self::Repository(_) => "#pk = :repo",
Self::RepositoryBranch(_, _) => "#pk = :repo and #sk = :branch",
Self::RepositoryBranchDescription(_, _, _) => {
"#pk = :repoBranch and #sk = :description"
}
}
}

fn expression_attribute_names(&self) -> HashMap<String, String> {
match self {
LockQuery::Hash(_) => HashMap::from([("#pk".to_string(), HASH_KEY.to_string())]),
LockQuery::HashRepository(_, _) | LockQuery::HashRepositoryBranch(_, _, _) => {
HashMap::from([
("#pk".to_string(), HASH_KEY.to_string()),
("#sk".to_string(), REPO_BRANCH_KEY.to_string()),
])
}
LockQuery::Owner(_) => HashMap::from([("#pk".to_string(), OWNER_KEY.to_string())]),
LockQuery::OwnerRepository(_, _) | LockQuery::OwnerRepositoryBranch(_, _, _) => {
HashMap::from([
("#pk".to_string(), OWNER_KEY.to_string()),
("#sk".to_string(), REPO_BRANCH_KEY.to_string()),
])
}
LockQuery::Repository(_) => HashMap::from([("#pk".to_string(), REPO_KEY.to_string())]),
LockQuery::RepositoryBranch(_, _) => HashMap::from([
Self::Hash(_) => HashMap::from([("#pk".to_string(), HASH_KEY.to_string())]),
Self::HashRepository(_, _) | Self::HashRepositoryBranch(_, _, _) => HashMap::from([
("#pk".to_string(), HASH_KEY.to_string()),
("#sk".to_string(), REPO_BRANCH_KEY.to_string()),
]),
Self::Owner(_) => HashMap::from([("#pk".to_string(), OWNER_KEY.to_string())]),
Self::OwnerRepository(_, _) | Self::OwnerRepositoryBranch(_, _, _) => HashMap::from([
("#pk".to_string(), OWNER_KEY.to_string()),
("#sk".to_string(), REPO_BRANCH_KEY.to_string()),
]),
Self::Repository(_) => HashMap::from([("#pk".to_string(), REPO_KEY.to_string())]),
Self::RepositoryBranch(_, _) => HashMap::from([
("#pk".to_string(), REPO_KEY.to_string()),
("#sk".to_string(), BRANCH_KEY.to_string()),
]),
LockQuery::RepositoryBranchDescription(_, _, _) => HashMap::from([
Self::RepositoryBranchDescription(_, _, _) => HashMap::from([
("#pk".to_string(), REPO_BRANCH_KEY.to_string()),
("#sk".to_string(), DESC_KEY.to_string()),
]),
Expand All @@ -198,11 +190,11 @@ impl DynamoDbQuery for LockQuery {

fn expression_attribute_values(&self) -> HashMap<String, AttributeValue> {
match self {
LockQuery::Hash(hash) => HashMap::from([(
Self::Hash(hash) => HashMap::from([(
":hash".to_string(),
AttributeValue::B(Blob::new(hash.as_bytes())),
)]),
LockQuery::HashRepository(hash, repository) => HashMap::from([
Self::HashRepository(hash, repository) => HashMap::from([
(
":hash".to_string(),
AttributeValue::B(Blob::new(hash.as_bytes())),
Expand All @@ -212,7 +204,7 @@ impl DynamoDbQuery for LockQuery {
AttributeValue::B(Blob::new(repository.as_bytes())),
),
]),
LockQuery::HashRepositoryBranch(hash, repository, branch) => HashMap::from([
Self::HashRepositoryBranch(hash, repository, branch) => HashMap::from([
(
":hash".to_string(),
AttributeValue::B(Blob::new(hash.as_bytes())),
Expand All @@ -229,17 +221,17 @@ impl DynamoDbQuery for LockQuery {
)),
),
]),
LockQuery::Owner(owner) => {
Self::Owner(owner) => {
HashMap::from([(":owner".to_string(), AttributeValue::S(owner.clone()))])
}
LockQuery::OwnerRepository(owner, repository) => HashMap::from([
Self::OwnerRepository(owner, repository) => HashMap::from([
(":owner".to_string(), AttributeValue::S(owner.clone())),
(
":repo".to_string(),
AttributeValue::B(Blob::new(repository.as_bytes())),
),
]),
LockQuery::OwnerRepositoryBranch(owner, repository, branch) => HashMap::from([
Self::OwnerRepositoryBranch(owner, repository, branch) => HashMap::from([
(":owner".to_string(), AttributeValue::S(owner.clone())),
(
":repoBranch".to_string(),
Expand All @@ -253,11 +245,11 @@ impl DynamoDbQuery for LockQuery {
)),
),
]),
LockQuery::Repository(repository) => HashMap::from([(
Self::Repository(repository) => HashMap::from([(
":repo".to_string(),
AttributeValue::B(Blob::new(repository.as_bytes())),
)]),
LockQuery::RepositoryBranch(repository, branch) => HashMap::from([
Self::RepositoryBranch(repository, branch) => HashMap::from([
(
":repo".to_string(),
AttributeValue::B(Blob::new(repository.as_bytes())),
Expand All @@ -267,25 +259,23 @@ impl DynamoDbQuery for LockQuery {
AttributeValue::B(Blob::new(branch.as_bytes())),
),
]),
LockQuery::RepositoryBranchDescription(repository, branch, description) => {
HashMap::from([
(
":repoBranch".to_string(),
AttributeValue::B(Blob::new(
repository
.data()
.iter()
.chain(branch.data().iter())
.copied()
.collect::<Vec<u8>>(),
)),
),
(
":description".to_string(),
AttributeValue::S(description.clone()),
),
])
}
Self::RepositoryBranchDescription(repository, branch, description) => HashMap::from([
(
":repoBranch".to_string(),
AttributeValue::B(Blob::new(
repository
.data()
.iter()
.chain(branch.data().iter())
.copied()
.collect::<Vec<u8>>(),
)),
),
(
":description".to_string(),
AttributeValue::S(description.clone()),
),
]),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions lore-base/src/fs/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct FSLock {
}

impl FSLock {
pub fn acquire_file_lock(path: impl AsRef<Path>) -> std::io::Result<FSLock> {
pub fn acquire_file_lock(path: impl AsRef<Path>) -> std::io::Result<Self> {
let mut path = path.as_ref().to_path_buf();
let mut file_name = path
.file_name()
Expand All @@ -33,12 +33,12 @@ impl FSLock {
})
}

pub fn acquire_directory_lock(path: impl AsRef<Path>) -> std::io::Result<FSLock> {
pub fn acquire_directory_lock(path: impl AsRef<Path>) -> std::io::Result<Self> {
let path = path.as_ref().canonicalize()?.join("lock");
Self::acquire_exact_path(&path)
}

fn acquire_exact_path(path: impl AsRef<Path> + Copy) -> std::io::Result<FSLock> {
fn acquire_exact_path(path: impl AsRef<Path> + Copy) -> std::io::Result<Self> {
let mut retry = 2;
let file = loop {
let file = OpenOptions::new()
Expand Down
2 changes: 1 addition & 1 deletion lore-base/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ pub struct TokioSettings {

impl Default for TokioSettings {
fn default() -> Self {
TokioSettings {
Self {
max_blocking_threads: default_blocking_threads(),
thread_keep_alive_seconds: default_thread_keep_alive(),
worker_threads: None,
Expand Down
6 changes: 3 additions & 3 deletions lore-base/src/types/fragment_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl From<FragmentFlags> for u32 {

impl From<u32> for FragmentFlags {
fn from(value: u32) -> Self {
FragmentFlags::from_bits_truncate(value)
Self::from_bits_truncate(value)
}
}

Expand All @@ -65,7 +65,7 @@ impl std::cmp::PartialEq<FragmentFlags> for u32 {
impl std::ops::BitAnd<FragmentFlags> for u32 {
type Output = Self;

fn bitand(self, rhs: FragmentFlags) -> u32 {
fn bitand(self, rhs: FragmentFlags) -> Self {
self & rhs.bits()
}
}
Expand All @@ -79,7 +79,7 @@ impl std::ops::BitAndAssign<FragmentFlags> for u32 {
impl std::ops::BitOr<FragmentFlags> for u32 {
type Output = Self;

fn bitor(self, rhs: FragmentFlags) -> u32 {
fn bitor(self, rhs: FragmentFlags) -> Self {
self | rhs.bits()
}
}
Expand Down
Loading