You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bifromq.apache.org by "liaodn (via GitHub)" <gi...@apache.org> on 2026/03/27 06:21:56 UTC
[PR] feat(core): make plugin FQN configs optional with strict-or-graceful … [bifromq]
liaodn opened a new pull request, #237:
URL: https://github.com/apache/bifromq/pull/237
…loading
Make authProviderFQN, resourceThrottlerFQN, and settingProviderFQN in standalone.yml optional to improve local dev/test ergonomics.
- If a *FQN field is explicitly set, treat it as a hard requirement: BifroMQ will fail fast on startup if the plugin class is missing or fails to initialize.
- If the field is omitted, apply auto-selection logic:
1. Discover all registered custom plugins for the extension point.
2. Sort by plugin key (byte-wise alphabetical) and pick the first.
3. Fall back to built-in default only if no custom plugins exist.
This provides a clear contract for production (explicit = strict) while keeping local development simple and low-friction.
Fixes #236
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bifromq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: make plugin FQN configs optional with strict-or-graceful loading [bifromq]
Posted by "liaodn (via GitHub)" <gi...@apache.org>.
liaodn commented on code in PR #237:
URL: https://github.com/apache/bifromq/pull/237#discussion_r3007744553
##########
bifromq-plugin/bifromq-plugin-auth-provider-helper/src/test/java/org/apache/bifromq/plugin/authprovider/AuthProviderManagerTest.java:
##########
@@ -133,18 +136,52 @@ public void pluginSpecified() {
}
@Test
+ public void pluginNotSpecifiedWithSingleProvider() {
+ manager = new AuthProviderManager(null, pluginManager, settingProvider, eventCollector);
+ when(mockProvider.auth(mockAuth3Data)).thenReturn(
+ CompletableFuture.completedFuture(MQTT3AuthResult.newBuilder()
+ .setReject(Reject.newBuilder().setCode(Reject.Code.BadPass).build()).build()));
+ MQTT3AuthResult result = manager.auth(mockAuth3Data).join();
+ assertEquals(result.getTypeCase(), MQTT3AuthResult.TypeCase.REJECT);
+ assertEquals(result.getReject().getCode(), Reject.Code.BadPass);
+ manager.close();
+ }
+
+ @Test
+ public void pluginNotSpecifiedWithMultipleProviders() {
+ IAuthProvider provider1 = new FirstTestAuthProvider();
+ IAuthProvider provider2 = new SecondTestAuthProvider();
+
+ when(pluginManager.getExtensions(IAuthProvider.class)).thenReturn(
+ Arrays.asList(provider1, provider2));
+ manager = new AuthProviderManager(null, pluginManager, settingProvider, eventCollector);
+
+ MQTT3AuthResult result = manager.auth(mockAuth3Data).join();
+ // Should use one of the providers (order depends on HashMap keySet iteration)
Review Comment:
Good point! The impl is deterministic (uses TreeMap by class name). Will fix the comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bifromq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: make plugin FQN configs optional with strict-or-graceful loading [bifromq]
Posted by "popduke (via GitHub)" <gi...@apache.org>.
popduke merged PR #237:
URL: https://github.com/apache/bifromq/pull/237
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bifromq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: make plugin FQN configs optional with strict-or-graceful loading [bifromq]
Posted by "popduke (via GitHub)" <gi...@apache.org>.
popduke commented on code in PR #237:
URL: https://github.com/apache/bifromq/pull/237#discussion_r3007331343
##########
bifromq-plugin/bifromq-plugin-auth-provider-helper/src/test/java/org/apache/bifromq/plugin/authprovider/AuthProviderManagerTest.java:
##########
@@ -133,18 +136,52 @@ public void pluginSpecified() {
}
@Test
+ public void pluginNotSpecifiedWithSingleProvider() {
+ manager = new AuthProviderManager(null, pluginManager, settingProvider, eventCollector);
+ when(mockProvider.auth(mockAuth3Data)).thenReturn(
+ CompletableFuture.completedFuture(MQTT3AuthResult.newBuilder()
+ .setReject(Reject.newBuilder().setCode(Reject.Code.BadPass).build()).build()));
+ MQTT3AuthResult result = manager.auth(mockAuth3Data).join();
+ assertEquals(result.getTypeCase(), MQTT3AuthResult.TypeCase.REJECT);
+ assertEquals(result.getReject().getCode(), Reject.Code.BadPass);
+ manager.close();
+ }
+
+ @Test
+ public void pluginNotSpecifiedWithMultipleProviders() {
+ IAuthProvider provider1 = new FirstTestAuthProvider();
+ IAuthProvider provider2 = new SecondTestAuthProvider();
+
+ when(pluginManager.getExtensions(IAuthProvider.class)).thenReturn(
+ Arrays.asList(provider1, provider2));
+ manager = new AuthProviderManager(null, pluginManager, settingProvider, eventCollector);
+
+ MQTT3AuthResult result = manager.auth(mockAuth3Data).join();
+ // Should use one of the providers (order depends on HashMap keySet iteration)
Review Comment:
the comment is inaccurate, order should be deterministic, right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bifromq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: make plugin FQN configs optional with strict-or-graceful loading [bifromq]
Posted by "popduke (via GitHub)" <gi...@apache.org>.
popduke commented on code in PR #237:
URL: https://github.com/apache/bifromq/pull/237#discussion_r3007331343
##########
bifromq-plugin/bifromq-plugin-auth-provider-helper/src/test/java/org/apache/bifromq/plugin/authprovider/AuthProviderManagerTest.java:
##########
@@ -133,18 +136,52 @@ public void pluginSpecified() {
}
@Test
+ public void pluginNotSpecifiedWithSingleProvider() {
+ manager = new AuthProviderManager(null, pluginManager, settingProvider, eventCollector);
+ when(mockProvider.auth(mockAuth3Data)).thenReturn(
+ CompletableFuture.completedFuture(MQTT3AuthResult.newBuilder()
+ .setReject(Reject.newBuilder().setCode(Reject.Code.BadPass).build()).build()));
+ MQTT3AuthResult result = manager.auth(mockAuth3Data).join();
+ assertEquals(result.getTypeCase(), MQTT3AuthResult.TypeCase.REJECT);
+ assertEquals(result.getReject().getCode(), Reject.Code.BadPass);
+ manager.close();
+ }
+
+ @Test
+ public void pluginNotSpecifiedWithMultipleProviders() {
+ IAuthProvider provider1 = new FirstTestAuthProvider();
+ IAuthProvider provider2 = new SecondTestAuthProvider();
+
+ when(pluginManager.getExtensions(IAuthProvider.class)).thenReturn(
+ Arrays.asList(provider1, provider2));
+ manager = new AuthProviderManager(null, pluginManager, settingProvider, eventCollector);
+
+ MQTT3AuthResult result = manager.auth(mockAuth3Data).join();
+ // Should use one of the providers (order depends on HashMap keySet iteration)
Review Comment:
order should be deterministic
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bifromq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org