-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add client extension methods and refactor interfaces Refactor to use interfaces for enhanced flexibility and testability across various components like NatsJSContext and NatsConnection. Added new extension methods to easily create contexts for Object Store, Key-Value Store, and Services on NATS client and connection instances. * Add public `Context` properties to store interfaces Updated INatsObjStore, INatsKVContext, and INatsSvcContext interfaces to include public `Context` properties. This change ensures consistent access to the underlying context objects across various components. * dotnet format * Refactor context creation to use JetStream directly * Make extensions namespace NATS.Net * Removed debug print * Rename to JetStreamContext * Fix inheritdoc * Fix build warnings * Fix build warnings and add test * Fix test
- Loading branch information
Showing
28 changed files
with
321 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
using NATS.Client.Core; | ||
using NATS.Client.JetStream; | ||
|
||
namespace NATS.Client.JetStream; | ||
// ReSharper disable once CheckNamespace | ||
namespace NATS.Net; | ||
|
||
public static class NatsClientExtensions | ||
{ | ||
/// <summary> | ||
/// Creates a JetStream context using the provided NATS client. | ||
/// </summary> | ||
/// <param name="client">The NATS client used to create the JetStream context.</param> | ||
/// <returns>Returns an instance of <see cref="INatsJSContext"/> for interacting with JetStream.</returns> | ||
public static INatsJSContext CreateJetStreamContext(this INatsClient client) | ||
=> CreateJetStreamContext(client.Connection); | ||
|
||
/// <summary> | ||
/// Creates a JetStream context using the provided NATS connection. | ||
/// </summary> | ||
/// <param name="connection">The NATS connection used to create the JetStream context.</param> | ||
/// <returns>Returns an instance of <see cref="INatsJSContext"/> for interacting with JetStream.</returns> | ||
public static INatsJSContext CreateJetStreamContext(this INatsConnection connection) | ||
=> new NatsJSContext(connection); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using NATS.Client.Core; | ||
using NATS.Client.JetStream; | ||
using NATS.Client.KeyValueStore; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace NATS.Net; | ||
|
||
public static class NatsClientExtensions | ||
{ | ||
/// <summary> | ||
/// Creates a NATS Key-Value Store context using the specified NATS client. | ||
/// </summary> | ||
/// <param name="client">The NATS client instance.</param> | ||
/// <returns>An instance of <see cref="INatsKVContext"/> which can be used to interact with the Key-Value Store.</returns> | ||
public static INatsKVContext CreateKeyValueStoreContext(this INatsClient client) | ||
=> CreateKeyValueStoreContext(client.CreateJetStreamContext()); | ||
|
||
/// <summary> | ||
/// Creates a NATS Key-Value Store context using the specified NATS connection. | ||
/// </summary> | ||
/// <param name="connection">The NATS connection instance.</param> | ||
/// <returns>An instance of <see cref="INatsKVContext"/> which can be used to interact with the Key-Value Store.</returns> | ||
public static INatsKVContext CreateKeyValueStoreContext(this INatsConnection connection) | ||
=> CreateKeyValueStoreContext(connection.CreateJetStreamContext()); | ||
|
||
/// <summary> | ||
/// Creates a NATS Key-Value Store context using the specified NATS JetStream context. | ||
/// </summary> | ||
/// <param name="context">The NATS JetStream context instance.</param> | ||
/// <returns>An instance of <see cref="INatsKVContext"/> which can be used to interact with the Key-Value Store.</returns> | ||
public static INatsKVContext CreateKeyValueStoreContext(this INatsJSContext context) | ||
=> new NatsKVContext(context); | ||
} |
Oops, something went wrong.