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

Fix KV allow direct #879

Merged
merged 6 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 5 additions & 2 deletions src/NATS.Client/KeyValue/KeyValueConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using NATS.Client.Internals;
using NATS.Client.JetStream;
Expand Down Expand Up @@ -345,14 +346,15 @@ public KeyValueConfigurationBuilder AddSource(Source source) {
}

/// <summary>
/// This method is deactivated. Allow Direct is Required default on KV
/// Set whether to allow direct message access.
/// This is an optimization for Key Value since
/// This is an optimization for Key Value
/// but is not available on all account / jwt configuration.
/// </summary>
/// <param name="allowDirect">true to allow direct headers.</param>
/// <returns>The KeyValueConfigurationBuilder</returns>
[Obsolete("This method is deactivated. Allow Direct is Required default on KV")]
public KeyValueConfigurationBuilder WithAllowDirect(bool allowDirect) {
scBuilder.WithAllowDirect(allowDirect);
return this;
}

Expand Down Expand Up @@ -386,6 +388,7 @@ public KeyValueConfiguration Build() {
_name = Validator.Required(_name, "name");
scBuilder.WithName(ToStreamName(_name))
.WithAllowRollup(true)
.WithAllowDirect(true)
.WithDiscardPolicy(DiscardPolicy.New)
.WithDenyDelete(true);

Expand Down
16 changes: 9 additions & 7 deletions src/Tests/IntegrationTests/TestKeyValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,7 @@ public void TestDontGetNoResponders()

[Fact]
public void TestKeyValueTransform() {
Context.RunInJsServer(c =>
Context.RunInJsServer(AtLeast2_10_3,c =>
{
// get the kv management context
IKeyValueManagement kvm = c.CreateKeyValueManagementContext();
Expand Down Expand Up @@ -1465,20 +1465,22 @@ public void TestKeyValueTransform() {
kv1.Put(key1, Encoding.UTF8.GetBytes(mirrorSegment));
kv1.Put(key2, Encoding.UTF8.GetBytes(dontMirrorSegment));

Thread.Sleep(1000); // transforming takes some amount of time, otherwise the kv2.getKeys() fails
Thread.Sleep(5000); // transforming takes some amount of time, otherwise the kv2.getKeys() fails

IList<string> keys = kv1.Keys();
Assert.True(keys.Contains(key1));
Assert.True(keys.Contains(key2));

Assert.NotNull(kv1.Get(key1));
Assert.NotNull(kv1.Get(key2));
// TODO COME BACK ONCE SERVER IS FIXED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we reference what the issue is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if one is made.

// Assert.NotNull(kv1.Get(key1));
// Assert.NotNull(kv1.Get(key2));

IKeyValue kv2 = c.CreateKeyValueContext(kvName2);
keys = kv2.Keys();
Assert.True(keys.Contains(key1));
Assert.False(keys.Contains(key2));
Assert.NotNull(kv2.Get(key1));
Assert.Null(kv2.Get(key2));
// TODO COME BACK ONCE SERVER IS FIXED
// Assert.NotNull(kv2.Get(key1));
// Assert.Null(kv2.Get(key2));
});
}
}
Expand Down
Loading