Skip to content

Commit

Permalink
Update parameter order
Browse files Browse the repository at this point in the history
  • Loading branch information
masesdevelopers committed Oct 19, 2023
1 parent 7fb11b5 commit cf9dae7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
22 changes: 11 additions & 11 deletions src/net/KEFCore.SerDes/KEFCoreSerDes.Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public class EntityExtractor
/// <param name="cb">The <see cref="Action{T1, T2}"/> where data will be available</param>
/// <param name="token">The <see cref="CancellationToken"/> to use to stop execution</param>
/// <param name="onlyLatest">Start execution only for newest messages and does not execute for oldest, default is from beginning</param>
public static void FromTopic(ConsumerConfigBuilder consumerConfig, string topicName, CancellationToken token, Action<object?, Exception?> cb, bool onlyLatest = false)
public static void FromTopic(ConsumerConfigBuilder consumerConfig, string topicName, Action<object?, Exception?> cb, CancellationToken token, bool onlyLatest = false)
{
FromTopic<object>(consumerConfig, topicName, token, cb, onlyLatest);
FromTopic<object>(consumerConfig, topicName, cb, token, onlyLatest);
}

/// <summary>
Expand All @@ -53,9 +53,9 @@ public static void FromTopic(ConsumerConfigBuilder consumerConfig, string topicN
/// <param name="cb">The <see cref="Action{T1, T2}"/> where data will be available</param>
/// <param name="token">The <see cref="CancellationToken"/> to use to stop execution</param>
/// <param name="onlyLatest">Start execution only for newest messages and does not execute for oldest, default is from beginning</param>
public static void FromTopic(string bootstrapServer, string topicName, CancellationToken token, Action<object?, Exception?> cb, bool onlyLatest = false)
public static void FromTopic(string bootstrapServer, string topicName, Action<object?, Exception?> cb, CancellationToken token, bool onlyLatest = false)
{
FromTopic<object>(bootstrapServer, topicName, token, cb, onlyLatest);
FromTopic<object>(bootstrapServer, topicName, cb, token, onlyLatest);
}
/// <summary>
/// Extract information for Entity from <paramref name="bootstrapServer"/> within a <paramref name="topicName"/> and send them to <paramref name="cb"/>
Expand All @@ -66,11 +66,11 @@ public static void FromTopic(string bootstrapServer, string topicName, Cancellat
/// <param name="cb">The <see cref="Action{T1, T2}"/> where data will be available</param>
/// <param name="token">The <see cref="CancellationToken"/> to use to stop execution</param>
/// <param name="onlyLatest">Start execution only for newest messages and does not execute for oldest, default is from beginning</param>
public static void FromTopic<TEntity>(string bootstrapServer, string topicName, CancellationToken token, Action<TEntity?, Exception?> cb, bool onlyLatest = false)
public static void FromTopic<TEntity>(string bootstrapServer, string topicName, Action<TEntity?, Exception?> cb, CancellationToken token, bool onlyLatest = false)
where TEntity : class
{
ConsumerConfigBuilder consumerBuilder = ConsumerConfigBuilder.Create().WithBootstrapServers(bootstrapServer);
FromTopic<TEntity>(consumerBuilder, topicName, token, cb, onlyLatest);
FromTopic<TEntity>(consumerBuilder, topicName, cb, token, onlyLatest);
}

/// <summary>
Expand All @@ -82,7 +82,7 @@ public static void FromTopic<TEntity>(string bootstrapServer, string topicName,
/// <param name="cb">The <see cref="Action{T1, T2}"/> where data will be available</param>
/// <param name="token">The <see cref="CancellationToken"/> to use to stop execution</param>
/// <param name="onlyLatest">Start execution only for newest messages and does not execute for oldest, default is from beginning</param>
public static void FromTopic<TEntity>(ConsumerConfigBuilder consumerConfig, string topicName, CancellationToken token, Action<TEntity?, Exception?> cb, bool onlyLatest = false)
public static void FromTopic<TEntity>(ConsumerConfigBuilder consumerConfig, string topicName, Action<TEntity?, Exception?> cb, CancellationToken token, bool onlyLatest = false)
where TEntity : class
{
try
Expand Down Expand Up @@ -140,10 +140,10 @@ public static TEntity FromRecord<TEntity>(ConsumerRecord<byte[], byte[]> record,
/// <returns>The extracted entity</returns>
public static object FromRecord(ConsumerRecord<byte[], byte[]> record, bool throwUnmatch = false)
{
Type keySerializerType = null;
Type valueSerializerType = null;
Type keyType = null;
Type valueType = null;
Type? keySerializerType = null;
Type? valueSerializerType = null;
Type? keyType = null;
Type? valueType = null;

var headers = record.Headers();
if (headers != null)
Expand Down
12 changes: 7 additions & 5 deletions test/KEFCore.Extractor.Test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,20 @@ static void Main(string[] args)

KEFCore.CreateGlobalInstance();
Console.CancelKeyPress += Console_CancelKeyPress;
EntityExtractor.FromTopic(config.BootstrapServers, config.TopicToSubscribe, runApplication.Token, (entity, exception) =>
{
if (exception != null) { Console.Error.WriteLine(exception.Message); }
if (entity != null) { Console.Out.WriteLine(entity.ToString()); }
});
EntityExtractor.FromTopic(config.BootstrapServers, config.TopicToSubscribe, ReportData, runApplication.Token);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}

static void ReportData(object entity, Exception exception)
{
if (exception != null) { Console.Error.WriteLine(exception.Message); }
if (entity != null) { Console.Out.WriteLine(entity.ToString()); }
}

private static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
{
runApplication.Cancel();
Expand Down

0 comments on commit cf9dae7

Please sign in to comment.