com.alipay.remoting.rpc.protocol
Interface UserProcessor<T>

All Known Implementing Classes:
AbstractUserProcessor, AsyncUserProcessor, SyncUserProcessor

public interface UserProcessor<T>

Defined all functions for biz to process user defined request.


Nested Class Summary
static interface UserProcessor.ExecutorSelector
          Executor selector interface.
 
Method Summary
 Executor getExecutor()
          Get user executor.
 UserProcessor.ExecutorSelector getExecutorSelector()
          Getter.
 void handleRequest(BizContext bizCtx, AsyncContext asyncCtx, T request)
          Handle request with AsyncContext.
 Object handleRequest(BizContext bizCtx, T request)
          Handle request in sync way.
 String interest()
          The class name of user request.
 BizContext preHandleRequest(RemotingContext remotingCtx, T request)
          Pre handle request, to avoid expose RemotingContext directly to biz handle request logic.
 boolean processInIOThread()
          Whether deserialize and process biz logic in io thread.
 void setExecutorSelector(UserProcessor.ExecutorSelector executorSelector)
          Setter.
 boolean timeoutDiscard()
          Whether handle request timeout automatically, we call this fail fast processing when detect timeout.
 

Method Detail

preHandleRequest

BizContext preHandleRequest(RemotingContext remotingCtx,
                            T request)
Pre handle request, to avoid expose RemotingContext directly to biz handle request logic.

Parameters:
remotingCtx -
request -
Returns:

handleRequest

void handleRequest(BizContext bizCtx,
                   AsyncContext asyncCtx,
                   T request)
Handle request with AsyncContext.

Parameters:
bizCtx -
asyncCtx -
request -

handleRequest

Object handleRequest(BizContext bizCtx,
                     T request)
                     throws Exception
Handle request in sync way.

Parameters:
bizCtx -
request -
Returns:
Throws:
Exception

interest

String interest()
The class name of user request. Use String type to avoid classloader problem.

Returns:

getExecutor

Executor getExecutor()
Get user executor.

Returns:

processInIOThread

boolean processInIOThread()
Whether deserialize and process biz logic in io thread. Notice: If return true, this will have a strong impact on performance.

Returns:

timeoutDiscard

boolean timeoutDiscard()
Whether handle request timeout automatically, we call this fail fast processing when detect timeout. Notice: If you do not want to enable this feature, you need to override this method to return false, and then call BizContext.isRequestTimeout() to check by yourself if you want.

Returns:
true if you want to enable fail fast processing, otherwise return false

setExecutorSelector

void setExecutorSelector(UserProcessor.ExecutorSelector executorSelector)
Setter. Use this method to provide a executor selector.

Parameters:
executorSelector -

getExecutorSelector

UserProcessor.ExecutorSelector getExecutorSelector()
Getter.

Returns:


Copyright © 2018. All rights reserved.