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 57a956a commit 79a8eaa
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 @@ -129,9 +129,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 @@ -348,7 +350,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 @@ -711,7 +713,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 @@ -774,7 +776,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 @@ -1062,21 +1064,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")]
#[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 79a8eaa

Please sign in to comment.