C# Класс Summer.Batch.Infrastructure.Repeat.Support.RepeatTemplate

Simple implementation and base class for batch templates implementing RepeatOperations. Provides a framework including interceptors and policies. Subclasses just need to provide a method that gets the next result and one that waits for all the results to be returned from concurrent processes or threads. N.B. the template accumulates thrown exceptions during the iteration, and they are all processed together when the main loop ends (i.e. finished processing the items). Clients that do not want to stop execution when an exception is thrown can use a specific ICompletionPolicy that does not finish when exceptions are received. This is not the default behaviour. Clients that want to take some business action when an exception is thrown by the IRepeatCallback can consider using a custom IRepeatListener instead of trying to customise the ICompletionPolicy. This is generally a friendlier interface to implement, and the IRepeatListener#After(RepeatContext, RepeatStatus) method is passed in the result of the callback, which would be an instance of Exception if the business processing had thrown an exception. If the exception is not to be propagated to the caller, then a non-default ICompletionPolicy needs to be provided as well, but that could be off the shelf, with the business action implemented only in the interceptor.
Наследование: IRepeatOperations
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
Logger NLog.Logger

Открытые методы

Метод Описание
Iterate ( RepeatCallback callback ) : RepeatStatus

Execute the batch callback until the completion policy decides that we are finished. Wait for the whole batch to finish before returning even if the task executor is asynchronous.

RegisterListener ( IRepeatListener listener ) : void

Registers given listener.

SetListeners ( IRepeatListener listeners ) : void

Registers array of listeners.

Защищенные методы

Метод Описание
CanContinue ( RepeatStatus value ) : bool

Check return value from batch operation.

CreateInternalState ( IRepeatContext context ) : IRepeatInternalState

Create an internal state object that is used to store data needed internally in the scope of an iteration. Used by subclasses to manage the queueing and retrieval of asynchronous results. The default just provides an accumulation of exceptions instances for processing at the end of the batch.

ExecuteAfterInterceptors ( IRepeatContext context, RepeatStatus value ) : void

Convenience method to execute after interceptors on a callback result.

GetNextResult ( IRepeatContext context, RepeatCallback callback, IRepeatInternalState state ) : RepeatStatus

Get the next completed result, possibly executing several callbacks until one finally finishes. Normally a subclass would have to override both this method and CreateInternalState because the implementation of this method would rely on the details of the internal state.

IsComplete ( IRepeatContext context ) : bool

Delegates to the Completion policy.

IsComplete ( IRepeatContext context, RepeatStatus result ) : bool

Delegates to the Completion policy.

Start ( ) : IRepeatContext

Delegates the start to the Completion policy.

Update ( IRepeatContext context ) : void

Delegates to the completion policy.

WaitForResults ( IRepeatInternalState state ) : bool

If necessary, wait for results to come back from remote or concurrent processes. By default does nothing and returns true.

Приватные методы

Метод Описание
DoHandle ( System exception, IRepeatContext context, ICollection deferred ) : void

Handling exceptions.

ExecuteInternal ( RepeatCallback callback ) : RepeatStatus

HandleFinally ( ICollection deferred, IRepeatListener listeners, IRepeatContext context ) : void

Handling the finally from ExecuteInternal.

IsMarkedComplete ( IRepeatContext context ) : bool

Check that given context is marked as completed.

Rethrow ( System exception ) : void

rethrow the exception wrapped into a RepeatException.

UnwrapIfRethrown ( System exception ) : System.Exception

Unwrap the exception id it has been wrapped into a RepeatException.

Описание методов

CanContinue() защищенный Метод

Check return value from batch operation.
protected CanContinue ( RepeatStatus value ) : bool
value RepeatStatus
Результат bool

CreateInternalState() защищенный Метод

Create an internal state object that is used to store data needed internally in the scope of an iteration. Used by subclasses to manage the queueing and retrieval of asynchronous results. The default just provides an accumulation of exceptions instances for processing at the end of the batch.
protected CreateInternalState ( IRepeatContext context ) : IRepeatInternalState
context IRepeatContext
Результат IRepeatInternalState

ExecuteAfterInterceptors() защищенный Метод

Convenience method to execute after interceptors on a callback result.
protected ExecuteAfterInterceptors ( IRepeatContext context, RepeatStatus value ) : void
context IRepeatContext
value RepeatStatus
Результат void

GetNextResult() защищенный Метод

Get the next completed result, possibly executing several callbacks until one finally finishes. Normally a subclass would have to override both this method and CreateInternalState because the implementation of this method would rely on the details of the internal state.
 
protected GetNextResult ( IRepeatContext context, RepeatCallback callback, IRepeatInternalState state ) : RepeatStatus
context IRepeatContext
callback RepeatCallback
state IRepeatInternalState
Результат RepeatStatus

IsComplete() защищенный Метод

Delegates to the Completion policy.
protected IsComplete ( IRepeatContext context ) : bool
context IRepeatContext
Результат bool

IsComplete() защищенный Метод

Delegates to the Completion policy.
protected IsComplete ( IRepeatContext context, RepeatStatus result ) : bool
context IRepeatContext
result RepeatStatus
Результат bool

Iterate() публичный Метод

Execute the batch callback until the completion policy decides that we are finished. Wait for the whole batch to finish before returning even if the task executor is asynchronous.
public Iterate ( RepeatCallback callback ) : RepeatStatus
callback RepeatCallback
Результат RepeatStatus

RegisterListener() публичный Метод

Registers given listener.
public RegisterListener ( IRepeatListener listener ) : void
listener IRepeatListener
Результат void

SetListeners() публичный Метод

Registers array of listeners.
public SetListeners ( IRepeatListener listeners ) : void
listeners IRepeatListener
Результат void

Start() защищенный Метод

Delegates the start to the Completion policy.
protected Start ( ) : IRepeatContext
Результат IRepeatContext

Update() защищенный Метод

Delegates to the completion policy.
protected Update ( IRepeatContext context ) : void
context IRepeatContext
Результат void

WaitForResults() защищенный Метод

If necessary, wait for results to come back from remote or concurrent processes. By default does nothing and returns true.
protected WaitForResults ( IRepeatInternalState state ) : bool
state IRepeatInternalState
Результат bool

Описание свойств

Logger защищенное статическое свойство

Logger
protected static Logger,NLog Logger
Результат NLog.Logger