Class EntityExtractor
- Namespace
- MASES.EntityFrameworkCore.KNet.Serialization
- Assembly
- MASES.EntityFrameworkCore.KNet.Serialization.dll
This is an helper class to extract data information from Kafka Records stored in topics
public class EntityExtractor
- Inheritance
-
EntityExtractor
- Inherited Members
Methods
FromRawValueData(Type, Type, Type, Type, string, byte[], byte[], bool)
Extract information for Entity from recordValue in input
public static object FromRawValueData(Type keyType, Type valueContainer, Type keySerializerSelectorType, Type valueSerializerSelectorType, string topic, byte[] recordValue, byte[] recordKey, bool throwUnmatch = false)
Parameters
keyTypeTypeExpected key Type
valueContainerTypeExpected ValueContainer Type
keySerializerSelectorTypeTypeKey serializer to be used
valueSerializerSelectorTypeTypeValueContainer serializer to be used
topicstringThe Apache Kafka topic the data is coming from
recordValuebyte[]The Apache Kafka record value containing the information
recordKeybyte[]The Apache Kafka record key containing the information
throwUnmatchboolThrows exceptions if there is unmatch in data retrieve, e.g. a property not available or a not settable
Returns
- object
The extracted entity
FromRecord(ConsumerRecord<byte[], byte[]>, bool)
Extract information for Entity from record in input
public static object FromRecord(ConsumerRecord<byte[], byte[]> record, bool throwUnmatch = false)
Parameters
recordConsumerRecord<byte[], byte[]>The Apache Kafka record containing the information
throwUnmatchboolThrows exceptions if there is unmatch in data retrieve, e.g. a property not available or a not settable
Returns
- object
The extracted entity
FromRecord<TEntity>(ConsumerRecord<byte[], byte[]>, bool)
Extract information for Entity from record in input
public static TEntity FromRecord<TEntity>(ConsumerRecord<byte[], byte[]> record, bool throwUnmatch = false) where TEntity : class
Parameters
recordConsumerRecord<byte[], byte[]>The Apache Kafka record containing the information
throwUnmatchboolThrows exceptions if there is unmatch in data retrieve, e.g. a property not available or a not settable
Returns
- TEntity
The extracted entity
Type Parameters
TEntity
FromTopic(ConsumerConfigBuilder, string, Action<object?, Exception?>, CancellationToken, bool)
Extract information for Entity using consumerConfig configurtion within a topicName and send them to cb
public static void FromTopic(ConsumerConfigBuilder consumerConfig, string topicName, Action<object?, Exception?> cb, CancellationToken token, bool onlyLatest = false)
Parameters
consumerConfigConsumerConfigBuilderThe ConsumerConfigBuilder with configuration
topicNamestringThe topic containing the data
cbAction<object, Exception>The Action<T1, T2> where data will be available
tokenCancellationTokenThe CancellationToken to use to stop execution
onlyLatestboolStart execution only for newest messages and does not execute for oldest, default is from beginning
FromTopic(string, string, Action<object?, Exception?>, CancellationToken, bool)
Extract information for Entity from bootstrapServer within a topicName and send them to cb
public static void FromTopic(string bootstrapServer, string topicName, Action<object?, Exception?> cb, CancellationToken token, bool onlyLatest = false)
Parameters
bootstrapServerstringThe Apache Kafka bootstrap.servers
topicNamestringThe topic containing the data
cbAction<object, Exception>The Action<T1, T2> where data will be available
tokenCancellationTokenThe CancellationToken to use to stop execution
onlyLatestboolStart execution only for newest messages and does not execute for oldest, default is from beginning
FromTopic<TEntity>(ConsumerConfigBuilder, string, Action<TEntity?, Exception?>, CancellationToken, bool)
Extract information for Entity using consumerConfig configurtion within a topicName and send them to cb
public static void FromTopic<TEntity>(ConsumerConfigBuilder consumerConfig, string topicName, Action<TEntity?, Exception?> cb, CancellationToken token, bool onlyLatest = false) where TEntity : class
Parameters
consumerConfigConsumerConfigBuilderThe ConsumerConfigBuilder with configuration
topicNamestringThe topic containing the data
cbAction<TEntity, Exception>The Action<T1, T2> where data will be available
tokenCancellationTokenThe CancellationToken to use to stop execution
onlyLatestboolStart execution only for newest messages and does not execute for oldest, default is from beginning
Type Parameters
TEntityThe Entity type if it is known
FromTopic<TEntity>(string, string, Action<TEntity?, Exception?>, CancellationToken, bool)
Extract information for Entity from bootstrapServer within a topicName and send them to cb
public static void FromTopic<TEntity>(string bootstrapServer, string topicName, Action<TEntity?, Exception?> cb, CancellationToken token, bool onlyLatest = false) where TEntity : class
Parameters
bootstrapServerstringThe Apache Kafka bootstrap.servers
topicNamestringThe topic containing the data
cbAction<TEntity, Exception>The Action<T1, T2> where data will be available
tokenCancellationTokenThe CancellationToken to use to stop execution
onlyLatestboolStart execution only for newest messages and does not execute for oldest, default is from beginning
Type Parameters
TEntityThe Entity type if it is known