- Add RequestOriginParser interface to extract request origin from the HTTP request
- Some code refinement
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
- When amount of context exceeds the threshold, the `NullContext` will be set to current thread local. Thus, when checking context in `CtSph#entry`, once `NullContext` detected, the entry will not do rule checking on the slot chain.
- Cache the default context during initialization. Then when amount of context exceeds the threshold, entries under default context can do rule checking under default context.
- Enhance the error message
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
- Add several `asyncEntry` method in `Sph` interface and `SphU` class.
- Add a new `AsyncEntry` class for asynchronous entry representation. Some refactor for `CtEntry`.
- Refactored `CtSph` and implement `asyncEntryInternal` for asynchronous entry.
- Add `runOnContext` and `replaceContext` method in `ContextUtil` for context switching.
- Support extensible `SlotChainBuilder` using SPI mechanism
- Add a `SlotChainProvider` to load slot chain builder and create new slot chains
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
- Abstract a universal `MetricsRepository` interface so that users can implement their own metrics persistence.
- Reuse original in-memory implementation (`InMemoryMetricsRepository`) as the default repository.
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
- Add `close` method in WritableDataSource (to extend AutoCloseable in JDK 1.7 later)
- Separate the writable file data source from original class
- Add a sample to show how to register data sources via Sentinel init mechanism
- Separate a writable data source registry from original handler to make it clear
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
- Spilt DataSource into two types: ReadableDataSource and WritableDataSource
- The AbstractDataSource now is read-only
- Refactor the file data source for writable implementation
- Rename: ConfigParser -> Converter (represents both encoder `T -> S` and decoder `S -> T`)
- Some other refinement
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
- The method from the signature will return the method of interface, so we need to resolve declared method in target class
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
- Fix incorrect usage. It's not thread-safe when comparing and updating `minRt`, but it's okay since the actual minimum RT often matches free load.
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
* Optimize for leap array
- Fix a bug: old position is not cleaned when inserting into a new (empty) position
- Reuse buckets for optimization
- The strategy is now changed: deprecated buckets will not be reset until newer time triggered. LeapArray is responsible for filtering the deprecated buckets (e.g. in `list` or `values`)
- Update test cases
Signed-off-by: Eric Zhao <sczyh16@gmail.com>