-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Confluent.Kafka; | ||
|
||
namespace Streamiz.Kafka.Net.Processors | ||
{ | ||
/// <summary> | ||
/// Forward the source partition as the sink partition of the record if there is enough sink partitions, Partition.Any otherwise | ||
/// </summary> | ||
/// <typeparam name="K">Key record type</typeparam> | ||
/// <typeparam name="V">Value record type</typeparam> | ||
public class DefaultStreamPartitioner<K, V> : IStreamPartitioner<K, V> | ||
{ | ||
/// <summary> | ||
/// Function used to determine how records are distributed among partitions of the topic | ||
/// </summary> | ||
/// <param name="topic">Sink topic name</param> | ||
/// <param name="key">record's key</param> | ||
/// <param name="value">record's value</param> | ||
/// <param name="sourcePartition">record's source partition</param> | ||
/// <param name="numPartitions">number partitions of the sink topic</param> | ||
/// <returns>Return the source partition as the sink partition of the record if there is enough sink partitions, Partition.Any otherwise</returns> | ||
public Partition Partition(string topic, K key, V value, Partition sourcePartition, int numPartitions) | ||
{ | ||
if (sourcePartition.Value <= numPartitions - 1) | ||
return sourcePartition; | ||
return Confluent.Kafka.Partition.Any; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.