Browse Source

Add Sph.entryWithPriority() method to receive args

Signed-off-by: Carpenter Lee <hooleeucas@163.com>
master
Carpenter Lee 6 years ago
parent
commit
5d2170282f
2 changed files with 26 additions and 1 deletions
  1. +9
    -1
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/CtSph.java
  2. +17
    -0
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/Sph.java

+ 9
- 1
sentinel-core/src/main/java/com/alibaba/csp/sentinel/CtSph.java View File

@@ -109,7 +109,8 @@ public class CtSph implements Sph {
return asyncEntry;
}

private AsyncEntry asyncEntryInternal(ResourceWrapper resourceWrapper, int count, Object... args) throws BlockException {
private AsyncEntry asyncEntryInternal(ResourceWrapper resourceWrapper, int count, Object... args)
throws BlockException {
return asyncEntryWithPriorityInternal(resourceWrapper, count, false, args);
}

@@ -321,4 +322,11 @@ public class CtSph implements Sph {
StringResourceWrapper resource = new StringResourceWrapper(name, type);
return entryWithPriority(resource, count, prioritized);
}

@Override
public Entry entryWithPriority(String name, EntryType type, int count, boolean prioritized, Object... args)
throws BlockException {
StringResourceWrapper resource = new StringResourceWrapper(name, type);
return entryWithPriority(resource, count, prioritized, args);
}
}

+ 17
- 0
sentinel-core/src/main/java/com/alibaba/csp/sentinel/Sph.java View File

@@ -169,4 +169,21 @@ public interface Sph {
* @since 1.4.0
*/
Entry entryWithPriority(String name, EntryType type, int count, boolean prioritized) throws BlockException;

/**
* Create a protected resource with priority.
*
* @param name the unique name for the protected resource
* @param type the resource is an inbound or an outbound method. This is used
* to mark whether it can be blocked when the system is unstable
* @param count the count that the resource requires
* @param prioritized whether the entry is prioritized
* @param args the parameters of the method. It can also be counted by setting hot parameter
* rule
* @return entry get
* @throws BlockException if the block criteria is met
* @since 1.5.0
*/
Entry entryWithPriority(String name, EntryType type, int count, boolean prioritized, Object... args)
throws BlockException;
}

Loading…
Cancel
Save