Add Sph.entryWithPriority() method to receive args

Signed-off-by: Carpenter Lee <hooleeucas@163.com>
This commit is contained in:
Carpenter Lee 2019-02-25 11:37:44 +08:00
parent b309dbe835
commit 5d2170282f
2 changed files with 26 additions and 1 deletions

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);
}
}

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;
}