-
Notifications
You must be signed in to change notification settings - Fork 8.2k
How to Use
jialianglinjl edited this page Jun 25, 2018
·
36 revisions
- "Hello world"
- Resource
- How it works
- Flow Control & Shapping
- Flow Shaping: Pace Limiter
- Flow Shaping: Warm Up
- Degrade
- System Protection
- Admin Console
- Rules Management
- Extension
- [Adapt to Other Frameworks]
- Demos
- Trouble Shooting & Logs
The following is a basic “Hello World” implementation of a resource definition:
public void helloWorld() {
Entry entry = null;
try {
// Resource name that can identify the protected logic
entry = SphU.entry("HelloWorld");
/**
* BIZ Logic that need protection
*/
} catch (BlockException e) {
/**
* Fail to enter, blocked by rules
*/
} finally {
if (entry != null) {
entry.exit();
}
}
}or we can also use 'if' and 'else' to define resource:
public void helloWorld(){
if(SphO.entry("HelloWorld")){
try {
/**
* BIZ Logic that need protection
*/
} finally {
SphO.exit();
}
}else{
/**
* Fail to enter, blocked by rules
*/
}
}Demos can be found in: demo
Resource is the key concept in sentinel. It can be anything in java code, a method, a service, or even a code snippet. Once a block is wrapped by API SphO.entry(Resource name) and entry.exit() or SphO.entry("HelloWorld") and 'entry.exit()', a resource is created. For resources, sentinel provides real time metrics, and dynamic rules.
Besides hard code API, Sentinel also provides proxies or AOP for most popular frameworks, you can use it without too much invasion.
-
文档
-
Documents
- Read Me
- Introduction
- How to Use
- How it Works
- Flow Control
- Parameter Flow Control
- Cluster Flow Control
- API Gateway Flow Control
- Circuit Breaking
- Adaptive System Protection
- Metrics
- General Configuration
- Dynamic Rule Configuration
- Dashboard
- Integrations with open-source frameworks
- Contribution Guideline