Skip to content

Commit

Permalink
Add placement configuration to key-value and object store (#650)
Browse files Browse the repository at this point in the history
* Add placement configuration to key-value store

* Add placement configuration to object store
  • Loading branch information
mtmk authored Oct 9, 2024
1 parent 3b6d431 commit 9d89723
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
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

0 comments on commit 9d89723

Please sign in to comment.