demo: Update slot chain SPI demo (#1581)
Signed-off-by: yunfeiyanggzq <yunfeiyang@buaa.edu.cn>
This commit is contained in:
parent
57f9bc7a6a
commit
5e1a443663
|
|
@ -19,12 +19,14 @@ import com.alibaba.csp.sentinel.context.Context;
|
||||||
import com.alibaba.csp.sentinel.node.DefaultNode;
|
import com.alibaba.csp.sentinel.node.DefaultNode;
|
||||||
import com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot;
|
import com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot;
|
||||||
import com.alibaba.csp.sentinel.slotchain.ResourceWrapper;
|
import com.alibaba.csp.sentinel.slotchain.ResourceWrapper;
|
||||||
|
import com.alibaba.csp.sentinel.spi.SpiOrder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An example slot that records current context and entry resource.
|
* An example slot that records current context and entry resource.
|
||||||
*
|
*
|
||||||
* @author Eric Zhao
|
* @author Eric Zhao
|
||||||
*/
|
*/
|
||||||
|
@SpiOrder(-3500)
|
||||||
public class DemoSlot extends AbstractLinkedProcessorSlot<DefaultNode> {
|
public class DemoSlot extends AbstractLinkedProcessorSlot<DefaultNode> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,11 @@ import com.alibaba.csp.sentinel.slotchain.SlotChainBuilder;
|
||||||
import com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder;
|
import com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An example slot chain builder. To activate this slot chain builder,
|
|
||||||
* add the class name to corresponding SPI file in `resource/META-INF/services` directory.
|
|
||||||
*
|
|
||||||
* @author Eric Zhao
|
* @author Eric Zhao
|
||||||
|
*
|
||||||
|
* @deprecated since 1.7.2, we can use @SpiOrder(-3500) to adjust the order of {@link DemoSlot},
|
||||||
|
* this class is reserved for compatibility with older versions.
|
||||||
*/
|
*/
|
||||||
public class DemoSlotChainBuilder implements SlotChainBuilder {
|
@Deprecated
|
||||||
|
public class DemoSlotChainBuilder extends DefaultSlotChainBuilder {
|
||||||
@Override
|
|
||||||
public ProcessorSlotChain build() {
|
|
||||||
ProcessorSlotChain chain = new DefaultSlotChainBuilder().build();
|
|
||||||
chain.addLast(new DemoSlot());
|
|
||||||
return chain;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Custom slot processor
|
||||||
|
com.alibaba.csp.sentinel.demo.slot.DemoSlot
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
# Custom slot chain builder
|
|
||||||
com.alibaba.csp.sentinel.demo.slot.DemoSlotChainBuilder
|
|
||||||
Loading…
Reference in New Issue