Skip to content

Commit

Permalink
Make IRecordDispatcher public and exchangeable
Browse files Browse the repository at this point in the history
  • Loading branch information
cpx86 authored and fedj committed Jun 13, 2018
1 parent 8e73b3c commit 7c5b3de
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
11 changes: 8 additions & 3 deletions Src/zipkin4net/Src/Dispatcher/IRecordDispatcher.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
namespace zipkin4net.Dispatcher
{
internal interface IRecordDispatcher
public interface IRecordDispatcher
{

/// <summary>
/// Stops the dispatcher.
/// </summary>
void Stop();

/// <summary>
/// Dispatches a record to the registered tracers.
/// </summary>
/// <returns>True if the record was dispatched. Otherwise false.</returns>
bool Dispatch(Record record);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace zipkin4net.Dispatcher
/// <summary>
/// Dispatch messages asynchronously in order using an ActionBlock
/// </summary>
internal class InOrderAsyncActionBlockDispatcher : IRecordDispatcher
public class InOrderAsyncActionBlockDispatcher : IRecordDispatcher
{
private readonly ActionBlock<Record> _actionBlock;
private readonly TimeSpan _timeoutOnStop;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace zipkin4net.Dispatcher
/// <summary>
/// Dispatch messages asynchronously in order using a concurrent queue and a consumer task
/// </summary>
internal class InOrderAsyncQueueDispatcher : IRecordDispatcher
public class InOrderAsyncQueueDispatcher : IRecordDispatcher
{
private readonly Action<Record> _pushToTracers;
private readonly int _maxCapacity;
Expand Down
6 changes: 5 additions & 1 deletion Src/zipkin4net/Src/TraceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ public static bool Start(ILogger logger)
return Start(logger, new InOrderAsyncQueueDispatcher(Push));
}

internal static bool Start(ILogger logger, IRecordDispatcher dispatcher)
/// <summary>
/// Start tracing, records will be forwarded to the registered tracers, using the provided dispatcher.
/// </summary>
/// <returns>True if successfully started, false if error or the service was already running.</returns>
public static bool Start(ILogger logger, IRecordDispatcher dispatcher)
{
if (Interlocked.CompareExchange(ref _status, (int)Status.Started, (int)Status.Stopped) ==
(int)Status.Stopped)
Expand Down

0 comments on commit 7c5b3de

Please sign in to comment.