Fork me on GitHub
Show / Hide Table of Contents

Class TimeLimiter

TimeLimiter implementation

Inheritance
System.Object
TimeLimiter
Implements
ComposableAsync.IDispatcher
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: RateLimiter
Assembly: RateLimiter.dll
Syntax
public class TimeLimiter : IDispatcher

Methods

| Improve this Doc View Source

Clone()

Declaration
public IDispatcher Clone()
Returns
Type Description
ComposableAsync.IDispatcher
| Improve this Doc View Source

Compose(IAwaitableConstraint[])

Compose various IAwaitableConstraint in a TimeLimiter

Declaration
public static TimeLimiter Compose(params IAwaitableConstraint[] constraints)
Parameters
Type Name Description
IAwaitableConstraint[] constraints
Returns
Type Description
TimeLimiter
| Improve this Doc View Source

Dispatch(Action)

Perform the given task respecting the time constraint

Declaration
public void Dispatch(Action action)
Parameters
Type Name Description
System.Action action
| Improve this Doc View Source

Enqueue(Action)

Perform the given task respecting the time constraint

Declaration
public Task Enqueue(Action perform)
Parameters
Type Name Description
System.Action perform
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Enqueue(Action, CancellationToken)

Perform the given task respecting the time constraint

Declaration
public Task Enqueue(Action perform, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Action perform
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Enqueue(Func<Task>)

Perform the given task respecting the time constraint returning the result of given function

Declaration
public Task Enqueue(Func<Task> perform)
Parameters
Type Name Description
System.Func<System.Threading.Tasks.Task> perform
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Enqueue(Func<Task>, CancellationToken)

Perform the given task respecting the time constraint

Declaration
public Task Enqueue(Func<Task> perform, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Func<System.Threading.Tasks.Task> perform
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

Enqueue<T>(Func<T>)

Perform the given task respecting the time constraint returning the result of given function

Declaration
public Task<T> Enqueue<T>(Func<T> perform)
Parameters
Type Name Description
System.Func<T> perform
Returns
Type Description
System.Threading.Tasks.Task<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

Enqueue<T>(Func<T>, CancellationToken)

Perform the given task respecting the time constraint returning the result of given function

Declaration
public Task<T> Enqueue<T>(Func<T> perform, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Func<T> perform
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.Task<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

Enqueue<T>(Func<Task<T>>)

Perform the given task respecting the time constraint returning the result of given function

Declaration
public Task<T> Enqueue<T>(Func<Task<T>> perform)
Parameters
Type Name Description
System.Func<System.Threading.Tasks.Task<T>> perform
Returns
Type Description
System.Threading.Tasks.Task<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

Enqueue<T>(Func<Task<T>>, CancellationToken)

Perform the given task respecting the time constraint returning the result of given function

Declaration
public Task<T> Enqueue<T>(Func<Task<T>> perform, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Func<System.Threading.Tasks.Task<T>> perform
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.Task<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

GetFromMaxCountByInterval(Int32, TimeSpan)

Returns a TimeLimiter based on a maximum number of times during a given period

Declaration
public static TimeLimiter GetFromMaxCountByInterval(int maxCount, TimeSpan timeSpan)
Parameters
Type Name Description
System.Int32 maxCount
System.TimeSpan timeSpan
Returns
Type Description
TimeLimiter
| Improve this Doc View Source

GetPersistentTimeLimiter(Int32, TimeSpan, Action<DateTime>)

Create TimeLimiter that will save state using action passed through saveStateAction parameter.

Declaration
public static TimeLimiter GetPersistentTimeLimiter(int maxCount, TimeSpan timeSpan, Action<DateTime> saveStateAction)
Parameters
Type Name Description
System.Int32 maxCount

Maximum actions allowed per time interval.

System.TimeSpan timeSpan

Time interval limits are applied for.

System.Action<System.DateTime> saveStateAction

Action is used to save state.

Returns
Type Description
TimeLimiter

TimeLimiter instance with PersistentCountByIntervalAwaitableConstraint.

| Improve this Doc View Source

GetPersistentTimeLimiter(Int32, TimeSpan, Action<DateTime>, IEnumerable<DateTime>)

Create TimeLimiter with initial timestamps that will save state using action passed through saveStateAction parameter.

Declaration
public static TimeLimiter GetPersistentTimeLimiter(int maxCount, TimeSpan timeSpan, Action<DateTime> saveStateAction, IEnumerable<DateTime> initialTimeStamps)
Parameters
Type Name Description
System.Int32 maxCount

Maximum actions allowed per time interval.

System.TimeSpan timeSpan

Time interval limits are applied for.

System.Action<System.DateTime> saveStateAction

Action is used to save state.

System.Collections.Generic.IEnumerable<System.DateTime> initialTimeStamps

Initial timestamps.

Returns
Type Description
TimeLimiter

TimeLimiter instance with PersistentCountByIntervalAwaitableConstraint.

Implements

ComposableAsync.IDispatcher
  • Improve this Doc
  • View Source
Back to top Generated by DocFX