Skip to content

Commit

Permalink
Resolved issue of ObjStore GetInfo MTime returning 0 (#567)
Browse files Browse the repository at this point in the history
* Fixed version number sent to server and changed lang to .NET from C#. Same as V1 client.

* default version to 1.0.0

* changed default version to 2.0.0

* Use informational version attribute and cut down to get additional info such as -preview. Also changed name to .Net to .NET for the client name.

* Add filtering to KV method returning all keys

* Ignore KV keys filtering in Pre 2.10 tests

* Resolved issue of ObjStore GetInfo MTime returning 0

* Changed public StoredMessage.Time datatype to DateTimeOffset from string.
  • Loading branch information
darkwatchuk authored Jul 22, 2024
1 parent 5ea2445 commit 601e51e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/NATS.Client.JetStream/Models/StoredMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public record StoredMessage
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
#if NET6_0
public string Time { get; set; } = default!;
public DateTimeOffset Time { get; set; } = default!;
#else
#pragma warning disable SA1206
public required string Time { get; set; }
public required DateTimeOffset Time { get; set; }
#pragma warning restore SA1206
#endif

Expand Down
5 changes: 1 addition & 4 deletions src/NATS.Client.KeyValueStore/NatsKVStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,6 @@ public async ValueTask<NatsKVEntry<T>> GetEntryAsync<T>(string key, ulong revisi
}
}

if (!DateTimeOffset.TryParse(response.Message.Time, out var created))
throw new NatsKVException("Can't parse timestamp message value");

T? data;
NatsDeserializeException? deserializeException = null;
if (response.Message.Data.Length > 0)
Expand All @@ -282,7 +279,7 @@ public async ValueTask<NatsKVEntry<T>> GetEntryAsync<T>(string key, ulong revisi

return new NatsKVEntry<T>(Bucket, key)
{
Created = created,
Created = response.Message.Time,
Revision = response.Message.Seq,
Value = data,
UsedDirectGet = false,
Expand Down
2 changes: 2 additions & 0 deletions src/NATS.Client.ObjectStore/NatsObjStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,8 @@ public async ValueTask<ObjectMetadata> GetInfoAsync(string key, bool showDeleted
var buffer = new ReadOnlySequence<byte>(response.Message.Data);
var data = NatsObjJsonSerializer<ObjectMetadata>.Default.Deserialize(buffer) ?? throw new NatsObjException("Can't deserialize object metadata");

data.MTime = response.Message.Time;

if (!showDeleted && data.Deleted)
{
throw new NatsObjNotFoundException($"Object not found: {key}");
Expand Down

0 comments on commit 601e51e

Please sign in to comment.