Skip to content

Commit

Permalink
Make object store structures more resilient
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Pietrek <[email protected]>
  • Loading branch information
Jarema committed Oct 5, 2023
1 parent 76d16e7 commit cee81b6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions async-nats/src/jetstream/object_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ impl ObjectStore {
let bucket = self
.stream
.context
.get_object_store(&link_name)
.get_object_store(&link.bucket)
.await
.map_err(|err| GetError::with_source(GetErrorKind::Other, err))?;
.map_err(|err| {
GetError::with_source(GetErrorKind::Other, err)
})?;
let object = bucket.get(&link_name).await?;
return Ok(object);
}
Expand Down Expand Up @@ -349,7 +351,7 @@ impl ObjectStore {
chunks: object_chunks,
size: object_size,
digest: Some(format!("SHA-256={}", URL_SAFE.encode(digest))),
modified: OffsetDateTime::now_utc(),
modified: Some(OffsetDateTime::now_utc()),
deleted: false,
};

Expand Down Expand Up @@ -712,7 +714,7 @@ impl ObjectStore {
nuid: nuid::next().to_string(),
size: 0,
chunks: 0,
modified: OffsetDateTime::now_utc(),
modified: Some(OffsetDateTime::now_utc()),
digest: None,
deleted: false,
};
Expand Down Expand Up @@ -775,7 +777,7 @@ impl ObjectStore {
nuid: nuid::next().to_string(),
size: 0,
chunks: 0,
modified: OffsetDateTime::now_utc(),
modified: Some(OffsetDateTime::now_utc()),
digest: None,
deleted: false,
};
Expand Down Expand Up @@ -1063,21 +1065,26 @@ pub struct ObjectInfo {
/// Name of the object
pub name: String,
/// A short human readable description of the object.
#[serde(default)]
pub description: Option<String>,
/// Link this object points to, if any.
#[serde(default)]
pub options: Option<ObjectOptions>,
/// Name of the bucket the object is stored in.
pub bucket: String,
/// Unique identifier used to uniquely identify this version of the object.
#[serde(default)]
pub nuid: String,
/// Size in bytes of the object.
#[serde(default)]
pub size: usize,
/// Number of chunks the object is stored in.
#[serde(default)]
pub chunks: usize,
/// Date and time the object was last modified.
#[serde(with = "rfc3339")]
#[serde(default, with = "rfc3339::option")]
#[serde(rename = "mtime")]
pub modified: time::OffsetDateTime,
pub modified: Option<time::OffsetDateTime>,
/// Digest of the object stream.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub digest: Option<String>,
Expand Down

0 comments on commit cee81b6

Please sign in to comment.