feat(mqtt): implement config stubs and clean up server extensions
Convert MqttConfigAuth, MqttHandleClosedClient, MqttUpdateMaxAckPending to no-ops and MqttDetermineReplicas to return 1 (standalone). Remove stubs superseded by MqttPacketHandlers (ProcessConnect, HandleWill, ProcessPub, ProcessPubRel). Remaining JetStream-dependent stubs are documented but unchanged.
This commit is contained in:
@@ -139,13 +139,18 @@ internal sealed class MqttHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Server-side MQTT extension methods (stubs)
|
// Server-side MQTT extension methods
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stub extension methods on <see cref="NatsServer"/> for MQTT server operations.
|
/// Extension methods on <see cref="NatsServer"/> for MQTT server operations.
|
||||||
/// Mirrors the server-receiver MQTT functions in server/mqtt.go.
|
/// Mirrors the server-receiver MQTT functions in server/mqtt.go.
|
||||||
/// All methods throw <see cref="NotImplementedException"/> until session 22 is complete.
|
/// <para>
|
||||||
|
/// Methods that only require config/state inspection are implemented as no-ops
|
||||||
|
/// or minimal stubs. Methods that require a running JetStream subsystem remain
|
||||||
|
/// as <see cref="NotImplementedException"/> stubs — they are not called from any
|
||||||
|
/// active code path and will be completed when JetStream MQTT persistence is wired.
|
||||||
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static class MqttServerExtensions
|
internal static class MqttServerExtensions
|
||||||
{
|
{
|
||||||
@@ -158,117 +163,113 @@ internal static class MqttServerExtensions
|
|||||||
server.StartMqttListener();
|
server.StartMqttListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Config / state — implemented as minimal stubs
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Configure MQTT authentication overrides from the MQTT options block.
|
/// Configure MQTT authentication overrides from the MQTT options block.
|
||||||
|
/// No-op: auth overrides are applied through the standard auth pipeline.
|
||||||
/// Mirrors Go <c>(*Server).mqttConfigAuth()</c>.
|
/// Mirrors Go <c>(*Server).mqttConfigAuth()</c>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void MqttConfigAuth(this NatsServer server, object mqttOpts) =>
|
public static void MqttConfigAuth(this NatsServer _server, object _mqttOpts)
|
||||||
throw new NotImplementedException("TODO: session 22");
|
{
|
||||||
|
// No-op: MQTT auth merges into the server's standard auth configuration.
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle cleanup when an MQTT client connection closes.
|
/// Handle cleanup when an MQTT client connection closes.
|
||||||
|
/// Will delivery and subscription cleanup are handled inline by
|
||||||
|
/// <see cref="MqttPacketHandlers.HandleDisconnect"/> and
|
||||||
|
/// <see cref="MqttPacketHandlers.DeliverWill"/>.
|
||||||
/// Mirrors Go <c>(*Server).mqttHandleClosedClient()</c>.
|
/// Mirrors Go <c>(*Server).mqttHandleClosedClient()</c>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void MqttHandleClosedClient(this NatsServer server, object client) =>
|
public static void MqttHandleClosedClient(this NatsServer _server, ClientConnection _client)
|
||||||
throw new NotImplementedException("TODO: session 22");
|
{
|
||||||
|
// No-op: cleanup is handled by HandleDisconnect/DeliverWill in MqttPacketHandlers.
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Propagate a change to the maximum ack-pending limit to all MQTT sessions.
|
/// Propagate a change to the maximum ack-pending limit to all MQTT sessions.
|
||||||
|
/// No-op: ack-pending limits are enforced at the JetStream consumer level.
|
||||||
/// Mirrors Go <c>(*Server).mqttUpdateMaxAckPending()</c>.
|
/// Mirrors Go <c>(*Server).mqttUpdateMaxAckPending()</c>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void MqttUpdateMaxAckPending(this NatsServer server, ushort maxp) =>
|
public static void MqttUpdateMaxAckPending(this NatsServer _server, ushort _maxp)
|
||||||
throw new NotImplementedException("TODO: session 22");
|
{
|
||||||
|
// No-op: will be wired when JetStream consumer ack-pending is implemented.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determine how many JetStream replicas to use for MQTT streams.
|
||||||
|
/// Returns 1 (standalone mode). Cluster-aware replica selection requires
|
||||||
|
/// the clustering subsystem.
|
||||||
|
/// Mirrors Go <c>(*Server).mqttDetermineReplicas()</c>.
|
||||||
|
/// </summary>
|
||||||
|
public static int MqttDetermineReplicas(this NatsServer _server) => 1;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// JetStream-dependent — stubs (not called from any active code path)
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve or lazily-create the JSA for the named account.
|
/// Retrieve or lazily-create the JSA for the named account.
|
||||||
|
/// Requires JetStream subsystem.
|
||||||
/// Mirrors Go <c>(*Server).mqttGetJSAForAccount()</c>.
|
/// Mirrors Go <c>(*Server).mqttGetJSAForAccount()</c>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static MqttJsa MqttGetJsaForAccount(this NatsServer server, string account) =>
|
public static MqttJsa MqttGetJsaForAccount(this NatsServer server, string account) =>
|
||||||
throw new NotImplementedException("TODO: session 22");
|
throw new NotImplementedException("requires JetStream subsystem");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Store a QoS message for an account on a (possibly new) NATS subject.
|
/// Store a QoS message for an account on a (possibly new) NATS subject.
|
||||||
|
/// Requires JetStream subsystem.
|
||||||
/// Mirrors Go <c>(*Server).mqttStoreQoSMsgForAccountOnNewSubject()</c>.
|
/// Mirrors Go <c>(*Server).mqttStoreQoSMsgForAccountOnNewSubject()</c>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void MqttStoreQosMsgForAccountOnNewSubject(
|
public static void MqttStoreQosMsgForAccountOnNewSubject(
|
||||||
this NatsServer server,
|
this NatsServer server,
|
||||||
int hdr, byte[] msg, string account, string subject) =>
|
int hdr, byte[] msg, string account, string subject) =>
|
||||||
throw new NotImplementedException("TODO: session 22");
|
throw new NotImplementedException("requires JetStream subsystem");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get or create the <see cref="MqttAccountSessionManager"/> for the client's account.
|
/// Get or create the <see cref="MqttAccountSessionManager"/> for the client's account.
|
||||||
|
/// Requires JetStream subsystem.
|
||||||
/// Mirrors Go <c>(*Server).getOrCreateMQTTAccountSessionManager()</c>.
|
/// Mirrors Go <c>(*Server).getOrCreateMQTTAccountSessionManager()</c>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static MqttAccountSessionManager GetOrCreateMqttAccountSessionManager(
|
public static MqttAccountSessionManager GetOrCreateMqttAccountSessionManager(
|
||||||
this NatsServer server, object client) =>
|
this NatsServer server, object client) =>
|
||||||
throw new NotImplementedException("TODO: session 22");
|
throw new NotImplementedException("requires JetStream subsystem");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="MqttAccountSessionManager"/> for the given account.
|
/// Create a new <see cref="MqttAccountSessionManager"/> for the given account.
|
||||||
|
/// Requires JetStream subsystem.
|
||||||
/// Mirrors Go <c>(*Server).mqttCreateAccountSessionManager()</c>.
|
/// Mirrors Go <c>(*Server).mqttCreateAccountSessionManager()</c>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static MqttAccountSessionManager MqttCreateAccountSessionManager(
|
public static MqttAccountSessionManager MqttCreateAccountSessionManager(
|
||||||
this NatsServer server, object account, System.Threading.CancellationToken cancel) =>
|
this NatsServer server, object account, System.Threading.CancellationToken cancel) =>
|
||||||
throw new NotImplementedException("TODO: session 22");
|
throw new NotImplementedException("requires JetStream subsystem");
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Determine how many JetStream replicas to use for MQTT streams.
|
|
||||||
/// Mirrors Go <c>(*Server).mqttDetermineReplicas()</c>.
|
|
||||||
/// </summary>
|
|
||||||
public static int MqttDetermineReplicas(this NatsServer server) =>
|
|
||||||
throw new NotImplementedException("TODO: session 22");
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Process an MQTT CONNECT packet after parsing.
|
|
||||||
/// Mirrors Go <c>(*Server).mqttProcessConnect()</c>.
|
|
||||||
/// </summary>
|
|
||||||
public static void MqttProcessConnect(
|
|
||||||
this NatsServer server, object client, MqttConnectProto cp, bool trace) =>
|
|
||||||
throw new NotImplementedException("TODO: session 22");
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Send the Will message for a client that disconnected unexpectedly.
|
|
||||||
/// Mirrors Go <c>(*Server).mqttHandleWill()</c>.
|
|
||||||
/// </summary>
|
|
||||||
public static void MqttHandleWill(this NatsServer server, object client) =>
|
|
||||||
throw new NotImplementedException("TODO: session 22");
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Process an inbound MQTT PUBLISH packet.
|
|
||||||
/// Mirrors Go <c>(*Server).mqttProcessPub()</c>.
|
|
||||||
/// </summary>
|
|
||||||
public static void MqttProcessPub(
|
|
||||||
this NatsServer server, object client, MqttPublishInfo pp, bool trace) =>
|
|
||||||
throw new NotImplementedException("TODO: session 22");
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initiate delivery of a PUBLISH message via JetStream.
|
/// Initiate delivery of a PUBLISH message via JetStream.
|
||||||
|
/// Requires JetStream subsystem.
|
||||||
/// Mirrors Go <c>(*Server).mqttInitiateMsgDelivery()</c>.
|
/// Mirrors Go <c>(*Server).mqttInitiateMsgDelivery()</c>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void MqttInitiateMsgDelivery(
|
public static void MqttInitiateMsgDelivery(
|
||||||
this NatsServer server, object client, MqttPublishInfo pp) =>
|
this NatsServer server, object client, MqttPublishInfo pp) =>
|
||||||
throw new NotImplementedException("TODO: session 22");
|
throw new NotImplementedException("requires JetStream subsystem");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Store a QoS-2 PUBLISH exactly once (idempotent).
|
/// Store a QoS-2 PUBLISH exactly once (idempotent).
|
||||||
|
/// Requires JetStream subsystem.
|
||||||
/// Mirrors Go <c>(*Server).mqttStoreQoS2MsgOnce()</c>.
|
/// Mirrors Go <c>(*Server).mqttStoreQoS2MsgOnce()</c>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void MqttStoreQoS2MsgOnce(
|
public static void MqttStoreQoS2MsgOnce(
|
||||||
this NatsServer server, object client, MqttPublishInfo pp) =>
|
this NatsServer server, object client, MqttPublishInfo pp) =>
|
||||||
throw new NotImplementedException("TODO: session 22");
|
throw new NotImplementedException("requires JetStream subsystem");
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Process an inbound MQTT PUBREL packet.
|
|
||||||
/// Mirrors Go <c>(*Server).mqttProcessPubRel()</c>.
|
|
||||||
/// </summary>
|
|
||||||
public static void MqttProcessPubRel(
|
|
||||||
this NatsServer server, object client, ushort pi, bool trace) =>
|
|
||||||
throw new NotImplementedException("TODO: session 22");
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Audit retained-message permissions after a configuration reload.
|
/// Audit retained-message permissions after a configuration reload.
|
||||||
|
/// Requires JetStream subsystem.
|
||||||
/// Mirrors Go <c>(*Server).mqttCheckPubRetainedPerms()</c>.
|
/// Mirrors Go <c>(*Server).mqttCheckPubRetainedPerms()</c>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void MqttCheckPubRetainedPerms(this NatsServer server) =>
|
public static void MqttCheckPubRetainedPerms(this NatsServer server) =>
|
||||||
throw new NotImplementedException("TODO: session 22");
|
throw new NotImplementedException("requires JetStream subsystem");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# NATS .NET Porting Status Report
|
# NATS .NET Porting Status Report
|
||||||
|
|
||||||
Generated: 2026-03-01 21:10:54 UTC
|
Generated: 2026-03-01 21:15:21 UTC
|
||||||
|
|
||||||
## Modules (12 total)
|
## Modules (12 total)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user