alibaba / alibaba/Sentinel

[API-CHANGE] Bring nouveau Sentinel entry API in Sentinel 2.0 | Sentinel 2.0 全新 API model

Open
#2,845 4 comments 0 reactions 1 assignee Claimed by @sczyh30 View on GitHub
api-change kind/discussion kind/feature
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

## Issue Description

Type: *feature request*

### Describe what happened (or what feature you want)

There are some drawbacks to *legacy Sentinel API model*:

- Strategies during invocation (e.g. timeout cut-down, retry, bulkhead isolation) cannot be carried out due to the restriction of the API model (for the lack of "managed" model).
- Lacking capabilities of traffic scheduling (i.e. routing and load balancing).

![image](https://user-images.githubusercontent.com/9434884/202855281-f0d2bbad-dc4c-48a3-a470-e98ad0ac181c.png)

So we'd like to propose a nouveau Sentinel entry API in Sentinel 2.0.

![image](https://user-images.githubusercontent.com/9434884/202856101-9e78303f-de3a-44d0-984b-db2834c72b26.png)

An example of "managed" model:

```java
try {
// f (() -> R): your actual logic, wrapped with lamada
// fallbackSupplier (() -> R): generates the fallback object when fails
R result = Sentinel.execute(resourceName, f, fallbackSupplier, args);
} catch (BlockException e) {
// your block handler here
}
```

An example of "outside-wrapped" model (like legacy `entry`):

```java
try (Sentinel.entry(resourceName)) {
// your logic here
} catch (BlockException e) {
// your block handler here
}
```

NOTE: The legacy `SphU` and `SphO` API will not be deprecated, but we'll recommend using the new API for Sentinel 2.0.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.