diff --git a/NATS.Client.sln b/NATS.Client.sln index 930a9f0c9..053f52683 100644 --- a/NATS.Client.sln +++ b/NATS.Client.sln @@ -79,6 +79,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NATS.Client.ObjectStore.Tes EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.ObjectStore", "sandbox\Example.ObjectStore\Example.ObjectStore.csproj", "{51882883-A66E-4F95-A1AB-CFCBF71B4376}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nats.Client.Compat.ObjectStore", "tests\Nats.Client.Compat.ObjectStore\Nats.Client.Compat.ObjectStore.csproj", "{35578296-FF6C-4BA4-BEE5-C1A6E7DB7024}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.TlsFirst", "sandbox\Example.TlsFirst\Example.TlsFirst.csproj", "{88625045-978F-417F-9F51-A4E3A9718945}" EndProject Global @@ -203,6 +205,10 @@ Global {51882883-A66E-4F95-A1AB-CFCBF71B4376}.Debug|Any CPU.Build.0 = Debug|Any CPU {51882883-A66E-4F95-A1AB-CFCBF71B4376}.Release|Any CPU.ActiveCfg = Release|Any CPU {51882883-A66E-4F95-A1AB-CFCBF71B4376}.Release|Any CPU.Build.0 = Release|Any CPU + {35578296-FF6C-4BA4-BEE5-C1A6E7DB7024}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35578296-FF6C-4BA4-BEE5-C1A6E7DB7024}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35578296-FF6C-4BA4-BEE5-C1A6E7DB7024}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35578296-FF6C-4BA4-BEE5-C1A6E7DB7024}.Release|Any CPU.Build.0 = Release|Any CPU {88625045-978F-417F-9F51-A4E3A9718945}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {88625045-978F-417F-9F51-A4E3A9718945}.Debug|Any CPU.Build.0 = Debug|Any CPU {88625045-978F-417F-9F51-A4E3A9718945}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -242,6 +248,7 @@ Global {3F8840BA-4F91-4359-AA53-6B26823E7F55} = {4827B3EC-73D8-436D-AE2A-5E29AC95FD0C} {BB2F4EEE-1AB3-43F7-B004-6C9B3D52353E} = {C526E8AB-739A-48D7-8FC4-048978C9B650} {51882883-A66E-4F95-A1AB-CFCBF71B4376} = {95A69671-16CA-4133-981C-CC381B7AAA30} + {35578296-FF6C-4BA4-BEE5-C1A6E7DB7024} = {C526E8AB-739A-48D7-8FC4-048978C9B650} {88625045-978F-417F-9F51-A4E3A9718945} = {95A69671-16CA-4133-981C-CC381B7AAA30} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/NATS.Client.sln.DotSettings b/NATS.Client.sln.DotSettings index e0bb2621b..a5b44166a 100644 --- a/NATS.Client.sln.DotSettings +++ b/NATS.Client.sln.DotSettings @@ -8,4 +8,4 @@ True True True - True \ No newline at end of file + True diff --git a/src/NATS.Client.ObjectStore/NatsObjConfig.cs b/src/NATS.Client.ObjectStore/NatsObjConfig.cs index 80a1f3029..30e3ae8d2 100644 --- a/src/NATS.Client.ObjectStore/NatsObjConfig.cs +++ b/src/NATS.Client.ObjectStore/NatsObjConfig.cs @@ -33,7 +33,7 @@ public record NatsObjConfig(string Bucket) /// /// Type of backing storage to use. /// - public NatsObjStorageType? Storage { get; init; } + public NatsObjStorageType Storage { get; init; } /// /// How many replicas to keep for each key. diff --git a/src/NATS.Client.ObjectStore/NatsObjContext.cs b/src/NATS.Client.ObjectStore/NatsObjContext.cs index ebfb89a1a..d6ac8c55a 100644 --- a/src/NATS.Client.ObjectStore/NatsObjContext.cs +++ b/src/NATS.Client.ObjectStore/NatsObjContext.cs @@ -49,6 +49,7 @@ public async ValueTask CreateObjectStore(NatsObjConfig config, Can AllowDirect = true, Metadata = config.Metadata!, Retention = StreamConfigurationRetention.limits, + Compression = StreamConfigurationCompression.none, }; var stream = await _context.CreateStreamAsync(streamConfiguration, cancellationToken); diff --git a/tests/Nats.Client.Compat.ObjectStore/Nats.Client.Compat.ObjectStore.csproj b/tests/Nats.Client.Compat.ObjectStore/Nats.Client.Compat.ObjectStore.csproj new file mode 100644 index 000000000..e74912569 --- /dev/null +++ b/tests/Nats.Client.Compat.ObjectStore/Nats.Client.Compat.ObjectStore.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + enable + false + + + + + + + diff --git a/tests/Nats.Client.Compat.ObjectStore/Program.cs b/tests/Nats.Client.Compat.ObjectStore/Program.cs new file mode 100644 index 000000000..fc3c5b51d --- /dev/null +++ b/tests/Nats.Client.Compat.ObjectStore/Program.cs @@ -0,0 +1,66 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using NATS.Client.Core; +using NATS.Client.JetStream; +using NATS.Client.ObjectStore; + +/* + * Use nats-server > 2.10 + * .\client-compatibility.exe suite object-store default-bucket + */ + +var url = Environment.GetEnvironmentVariable("NATS_URL") ?? NatsOpts.Default.Url; +var opts = NatsOpts.Default with { Url = url }; +await using var nats = new NatsConnection(opts); +var js = new NatsJSContext(nats); +var ob = new NatsObjContext(js); + +Log($"Connected to NATS server {url}"); + +await using var sub = await nats.SubscribeAsync>("tests.object-store.default-bucket.>"); + +Log($"Subscribed to {sub.Subject}"); +var msg = await sub.Msgs.ReadAsync(); + +var config = JsonSerializer.Deserialize>(msg.Data.Span); + +Log($"Test message received: {config}"); + +await ob.CreateObjectStore(new NatsObjConfig(config!.Config.Bucket!)); + +await msg.ReplyAsync(default); + +void Log(string message) +{ + Console.WriteLine($"{DateTime.Now:hh:mm:ss} {message}"); +} + +public record ObjectStepConfig +{ + [JsonPropertyName("suite")] + public string? Suite { get; set; } + + [JsonPropertyName("test")] + public string? Test { get; set; } + + [JsonPropertyName("command")] + public string? Command { get; set; } + + [JsonPropertyName("url")] + public string? Url { get; set; } + + [JsonPropertyName("bucket")] + public string? Bucket { get; set; } + + [JsonPropertyName("object")] + public string? Object { get; set; } + + [JsonPropertyName("config")] + public T? Config { get; set; } +} + +public record BucketConfig +{ + [JsonPropertyName("bucket")] + public string? Bucket { get; set; } +}