Skip to content

Conversation

@z-soulx
Copy link

@z-soulx z-soulx commented Oct 17, 2025

Describe what this PR does / why we need it

This PR addresses the remaining issues from #3477:
add behavior limits and conflict warning logs with new unit tests
1 No existing unit tests — added new tests for better coverage.
2 TrafficShapingControllerFactory allowed unrestricted custom controlBehavior definitions.
3 No warning when configuration conflicts occurred.

This caused conflicts with future official behaviors (e.g., type 5).

Does this pull request fix one issue?

#3189 and #3477

Describe how you did it

1 Added unit tests to verify control behavior and configuration correctness.
2 Introduced controlBehavior range restriction:

  • Lower 8 bits are reserved for internal (official) extensions.
  • Custom user-defined behaviors now start from 256.

Describe how to verify it

unit tests

Special notes for reviews

Original initiator: myself — the initial PR (#3189) was incomplete and inactive
Perfected by: @icodening — this PR builds upon and improves his previous work.
This feature has been pending for 2–3 years; as the original author, I hope to help finalize it.
Thanks to @icodening for the collaboration and previous contributions — happy to sync anytime.

Comment on lines +36 to +48
/**
* Indicates whether this factory is a built-in Sentinel implementation.
* Built-in factories are allowed to use control behavior values in the reserved range [0, 255].
* User-defined factories should return {@code false} (default) and use values >= 256.
*
* This method is used internally for validation during factory registration to ensure
* proper namespace separation and prevent conflicts.
*
* @return {@code true} if this is a Sentinel built-in factory, {@code false} for user-defined implementations
*/
default boolean isBuiltIn() {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think built in impl could be override and improve by user, it seems no need to limit

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think built in impl could be override and improve by user, it seems no need to limit

The main point here is to give a light warning—keeping it flexible while still notifying the user.

For instance, the default is false (not built-in). If a user forces the override, it means they are aware of the warning and its consequences.

Thought process:
I spent a lot of time thinking about this. As a beginner, without any restrictions or warnings, maintaining and ensuring compatibility down the line could be a real challenge. I considered three options:

  1. Fully open: great flexibility, but tough to maintain and keep compatible.

  2. Light restriction (this one): default false, can still be overridden. ☑️

  3. Fully restricted: only custom interfaces with strict enforcement, but might limit third-party flexibility and design.

@LearningGp LearningGp self-requested a review October 22, 2025 10:40
@LearningGp LearningGp added area/flow-control Issues or PRs related to flow control kind/feature Category issues or prs related to feature request. labels Oct 22, 2025
@LearningGp LearningGp moved this to In progress in Sentinel Oct 22, 2025
@LearningGp LearningGp moved this from In progress to In review in Sentinel Oct 30, 2025
@LearningGp LearningGp moved this from In review to In progress in Sentinel Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/flow-control Issues or PRs related to flow control kind/feature Category issues or prs related to feature request.

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

4 participants