-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\NATS.Client.ObjectStore\NATS.Client.ObjectStore.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Memory<byte>>("tests.object-store.default-bucket.>"); | ||
|
||
Log($"Subscribed to {sub.Subject}"); | ||
var msg = await sub.Msgs.ReadAsync(); | ||
|
||
var config = JsonSerializer.Deserialize<ObjectStepConfig<BucketConfig>>(msg.Data.Span); | ||
|
||
Log($"Test message received: {config}"); | ||
|
||
await ob.CreateObjectStore(new NatsObjConfig(config!.Config.Bucket!)); | ||
Check warning on line 29 in tests/Nats.Client.Compat.ObjectStore/Program.cs GitHub Actions / memory test (release/v2.9.23)
Check warning on line 29 in tests/Nats.Client.Compat.ObjectStore/Program.cs GitHub Actions / memory test (release/v2.9.23)
Check warning on line 29 in tests/Nats.Client.Compat.ObjectStore/Program.cs GitHub Actions / dotnet (release/v2.9.23)
Check warning on line 29 in tests/Nats.Client.Compat.ObjectStore/Program.cs GitHub Actions / dotnet (release/v2.9.23)
Check warning on line 29 in tests/Nats.Client.Compat.ObjectStore/Program.cs GitHub Actions / memory test (latest)
Check warning on line 29 in tests/Nats.Client.Compat.ObjectStore/Program.cs GitHub Actions / memory test (latest)
Check warning on line 29 in tests/Nats.Client.Compat.ObjectStore/Program.cs GitHub Actions / dotnet (latest)
Check warning on line 29 in tests/Nats.Client.Compat.ObjectStore/Program.cs GitHub Actions / dotnet (latest)
Check warning on line 29 in tests/Nats.Client.Compat.ObjectStore/Program.cs GitHub Actions / memory test (main)
Check warning on line 29 in tests/Nats.Client.Compat.ObjectStore/Program.cs GitHub Actions / memory test (main)
Check warning on line 29 in tests/Nats.Client.Compat.ObjectStore/Program.cs GitHub Actions / dotnet (main)
|
||
|
||
await msg.ReplyAsync<object>(default); | ||
|
||
void Log(string message) | ||
{ | ||
Console.WriteLine($"{DateTime.Now:hh:mm:ss} {message}"); | ||
} | ||
|
||
public record ObjectStepConfig<T> | ||
{ | ||
[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; } | ||
} |