Conditional Modules #93

Open
opened 2020-06-01 22:58:57 +01:00 by Ghost · 0 comments
Ghost commented 2020-06-01 22:58:57 +01:00 (Migrated from codeberg.org)

Feature Request

Sub-Project

This is regarding:

  • core

Description

Commandler should be able to set a controller as conditional based on a predicate.

For example, if a module requires an API key to function, but the API key is not provided,
instead of deploying a broken module, we can instead log that the module has been omitted due to the conditional check.

This may come off similar to the testing logic to enable/disable a module, but this is meant to be different.
The testing logic to disable poorly behaving modules, and checks post initialization. The conditional check to load a module in the first place is for applications that may intentionally leave something unloaded during initialization.

This should probably be contributed to DeltaSpike rather than in Commandler.

Interface

@Conditional("${application.api.osu} != null")
@StandardController
public class OsuController {

    private Osu osu;

    public OsuController(ApiConfig config) {
         osu = new Osu(config.getOsuApiKey());
    }
}
# Feature Request <!-- This is for requesting new features, or improvements/additions to existing features. This is pre-filled with example values, feel free to remove them before populating the template. If you feel a heading is irrelevant, just remove it. --> ## Sub-Project <!-- Can you specify which sub-project(s) this is relevant to? If you aren't sure, or this is a proposal for a new sub-project, you can delete this. --> This is regarding: * core ## Description <!-- Explain what this is about, try to use full sentences, and make your point clear. --> Commandler should be able to set a controller as conditional based on a predicate. For example, if a module requires an API key to function, but the API key is not provided, instead of deploying a broken module, we can instead log that the module has been omitted due to the conditional check. This may come off similar to the testing logic to enable/disable a module, but this is meant to be different. The testing logic to disable poorly behaving modules, and checks post initialization. The conditional check to load a module in the first place is for applications that may intentionally leave something unloaded during initialization. This should probably be contributed to DeltaSpike rather than in Commandler. ## Interface <!-- In some cases you may wish to propose an interface or method names to help describe how you'd want to use this, or for others to discuss and improve ahead of time before final implementation. --> ```java @Conditional("${application.api.osu} != null") @StandardController public class OsuController { private Osu osu; public OsuController(ApiConfig config) { osu = new Osu(config.getOsuApiKey()); } } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
SethFalco/commandler#93
No description provided.