-
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.
Use STJ src-gen for ServerInfo and ClientOptions (#106)
* Use STJ src-gen for ClientOptions and ServerInfo * Fix deserialization of ServerInfo STJ src-gen does not support internal setters. Introduce a public interface instead to expose a read-only view of ServerInfo and make ServerInfo internal. * Remove defaults from src-gen options
- Loading branch information
Showing
8 changed files
with
163 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
namespace NATS.Client.Core; | ||
|
||
public interface IServerInfo | ||
{ | ||
string Id { get; } | ||
|
||
string Name { get; } | ||
|
||
string Version { get; } | ||
|
||
long ProtocolVersion { get; } | ||
|
||
string GitCommit { get; } | ||
|
||
string GoVersion { get; } | ||
|
||
string Host { get; } | ||
|
||
int Port { get; } | ||
|
||
bool HeadersSupported { get; } | ||
|
||
bool AuthRequired { get; } | ||
|
||
bool TlsRequired { get; } | ||
|
||
bool TlsVerify { get; } | ||
|
||
bool TlsAvailable { get; } | ||
|
||
int MaxPayload { get; } | ||
|
||
bool JetStreamAvailable { get; } | ||
|
||
ulong ClientId { get; } | ||
|
||
string ClientIp { get; } | ||
|
||
string? Nonce { get; } | ||
|
||
string? Cluster { get; } | ||
|
||
bool ClusterDynamic { get; } | ||
|
||
string[]? ClientConnectUrls { get; } | ||
|
||
string[]? WebSocketConnectUrls { get; } | ||
|
||
bool LameDuckMode { get; } | ||
} |
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,10 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace NATS.Client.Core.Internal; | ||
|
||
[JsonSourceGenerationOptions(DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonSerializable(typeof(ServerInfo), GenerationMode = JsonSourceGenerationMode.Metadata)] | ||
[JsonSerializable(typeof(ClientOptions), GenerationMode = JsonSourceGenerationMode.Serialization)] | ||
internal sealed partial class JsonContext : JsonSerializerContext | ||
{ | ||
} |
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,77 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace NATS.Client.Core.Internal; | ||
|
||
// Defined from `type Info struct` in nats-server | ||
// https://github.com/nats-io/nats-server/blob/a23b1b7/server/server.go#L61 | ||
internal sealed record ServerInfo : IServerInfo | ||
{ | ||
[JsonPropertyName("server_id")] | ||
public string Id { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("server_name")] | ||
public string Name { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("version")] | ||
public string Version { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("proto")] | ||
public long ProtocolVersion { get; set; } | ||
|
||
[JsonPropertyName("git_commit")] | ||
public string GitCommit { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("go")] | ||
public string GoVersion { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("host")] | ||
public string Host { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("port")] | ||
public int Port { get; set; } | ||
|
||
[JsonPropertyName("headers")] | ||
public bool HeadersSupported { get; set; } | ||
|
||
[JsonPropertyName("auth_required")] | ||
public bool AuthRequired { get; set; } | ||
|
||
[JsonPropertyName("tls_required")] | ||
public bool TlsRequired { get; set; } | ||
|
||
[JsonPropertyName("tls_verify")] | ||
public bool TlsVerify { get; set; } | ||
|
||
[JsonPropertyName("tls_available")] | ||
public bool TlsAvailable { get; set; } | ||
|
||
[JsonPropertyName("max_payload")] | ||
public int MaxPayload { get; set; } | ||
|
||
[JsonPropertyName("jetstream")] | ||
public bool JetStreamAvailable { get; set; } | ||
|
||
[JsonPropertyName("client_id")] | ||
public ulong ClientId { get; set; } | ||
|
||
[JsonPropertyName("client_ip")] | ||
public string ClientIp { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("nonce")] | ||
public string? Nonce { get; set; } | ||
|
||
[JsonPropertyName("cluster")] | ||
public string? Cluster { get; set; } | ||
|
||
[JsonPropertyName("cluster_dynamic")] | ||
public bool ClusterDynamic { get; set; } | ||
|
||
[JsonPropertyName("connect_urls")] | ||
public string[]? ClientConnectUrls { get; set; } | ||
|
||
[JsonPropertyName("ws_connect_urls")] | ||
public string[]? WebSocketConnectUrls { get; set; } | ||
|
||
[JsonPropertyName("ldm")] | ||
public bool LameDuckMode { get; set; } | ||
} |
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 was deleted.
Oops, something went wrong.