Class McpTokenBucketConfig.Builder
java.lang.Object
com.soklet.McpTokenBucketConfig.Builder
- Enclosing class:
McpTokenBucketConfig
Single-threaded builder for immutable token-bucket configurations.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds an immutable finite configuration.Sets the maximum number of tokens held by one bucket.refillInterval(@NonNull Duration refillInterval) Sets the positive refill interval.refillTokens(@NonNull Long refillTokens) Sets the number of tokens replenished during one refill interval.
-
Method Details
-
capacity
Sets the maximum number of tokens held by one bucket.- Parameters:
capacity- positive token capacity- Returns:
- this builder
- Throws:
NullPointerException- ifcapacityis null
-
refillTokens
Sets the number of tokens replenished during one refill interval. This value is required and has no default.- Parameters:
refillTokens- positive refill quantity- Returns:
- this builder
- Throws:
NullPointerException- ifrefillTokensis null
-
refillInterval
Sets the positive refill interval. This value is required and has no default.- Parameters:
refillInterval- positive refill interval- Returns:
- this builder
- Throws:
NullPointerException- ifrefillIntervalis null
-
build
Builds an immutable finite configuration.- Returns:
- token-bucket configuration
- Throws:
IllegalStateException- if refill quantity or interval is absentIllegalArgumentException- if a numeric value is not positive or the refill interval cannot be represented in nanoseconds
-