Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add placement configuration to key-value and object store #650

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/NATS.Client.KeyValueStore/NatsKVConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public record NatsKVConfig
/// </summary>
public NatsKVRepublish? Republish { get; init; }

/// <summary>
/// Placement requirements for a key-value store stream.
/// </summary>
public Placement? Placement { get; init; }

/// <summary>
/// Use compressed storage.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/NATS.Client.KeyValueStore/NatsKVContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ private static StreamConfig CreateStreamConfig(NatsKVConfig config)
Compression = config.Compression ? StreamConfigCompression.S2 : StreamConfigCompression.None,
Storage = storage,
Republish = republish!,
Placement = config.Placement,
AllowRollupHdrs = true,
DenyDelete = true,
DenyPurge = false,
Expand Down
7 changes: 7 additions & 0 deletions src/NATS.Client.ObjectStore/NatsObjConfig.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using NATS.Client.JetStream.Models;

namespace NATS.Client.ObjectStore;

/// <summary>
Expand Down Expand Up @@ -40,6 +42,11 @@ public record NatsObjConfig(string Bucket)
/// </summary>
public int NumberOfReplicas { get; init; } = 1;

/// <summary>
/// Placement requirements for a object store stream.
/// </summary>
public Placement? Placement { get; init; }

/// <summary>
/// Additional metadata for the bucket.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/NATS.Client.ObjectStore/NatsObjContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async ValueTask<INatsObjStore> CreateObjectStoreAsync(NatsObjConfig confi
MaxBytes = config.MaxBytes ?? -1,
Storage = storage,
NumReplicas = config.NumberOfReplicas,
/* TODO: Placement = */
Placement = config.Placement,
Discard = StreamConfigDiscard.New,
AllowRollupHdrs = true,
AllowDirect = true,
Expand Down