Skip to main content

Feature Toggles

All of Coco's built-in capabilities are managed through stable CocoFeature identifiers and can be started and stopped declaratively on the application side. For feature selection, prefer YAML or @CocoFeatures; the older CocoConfigurer Java hook is kept only for compatibility and is no longer recommended.

Declaring via YAML

Disable features in application.yml through coco.features.disabled:

coco:
features:
disabled:
- mybatis-plus
- tenant
- data-permission

Declaring via annotation

You can also declare them through Java configuration:

@CocoFeatures(disabled = {
CocoFeature.TENANT,
CocoFeature.DATA_PERMISSION
})
@Configuration(proxyBeanMethods = false)
class ApplicationCocoConfiguration {
}

Dependency propagation

Features have dependency relationships. When you disable a feature that others depend on, the features that depend on it are automatically disabled as well, avoiding a half-assembled state.

For example, disabling mybatis-plus cascades to disable tenant, data-permission, and codegen, which depend on it.

Built-in feature identifiers

IdentifierFeatureDependencies
webWeb runtime
mybatis-plusMyBatis-Plus integration
auditAudit pipeline
securitySecurity context
tenantMulti-tenant isolationmybatis-plus, security
data-permissionData permissionmybatis-plus, security
openapiOpenAPI metadataweb, security
rate-limitRate limitingweb
idempotencyIdempotencyweb
schedulingDynamic scheduled tasks
lockDistributed lock
storageObject storage
messagingMessaging and events
cacheTwo-level cache
notificationNotification channels
captchaCaptcha
codegenCode generationmybatis-plus

Relationship to module-level switches

coco.features.disabled controls the assembly of an entire feature. Each feature also typically has a finer-grained enabled property internally (such as coco.idempotency.enabled), used to control specific behavior once the feature is assembled. These are different layers: the feature toggle decides "whether to load this module," and the module property decides "whether it takes effect after loading."