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
keyType
TypeExpected key Type
valueContainer
TypeExpected ValueContainer Type
keySerializerSelectorType
TypeKey serializer to be used
valueSerializerSelectorType
TypeValueContainer serializer to be used
topic
stringThe Apache Kafka topic the data is coming from
recordValue
byte[]The Apache Kafka record value containing the information
recordKey
byte[]The Apache Kafka record key containing the information
throwUnmatch
boolThrows 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
record
ConsumerRecord<byte[], byte[]>The Apache Kafka record containing the information
throwUnmatch
boolThrows 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
record
ConsumerRecord<byte[], byte[]>The Apache Kafka record containing the information
throwUnmatch
boolThrows 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
consumerConfig
ConsumerConfigBuilderThe ConsumerConfigBuilder with configuration
topicName
stringThe topic containing the data
cb
Action<object, Exception>The Action<T1, T2> where data will be available
token
CancellationTokenThe CancellationToken to use to stop execution
onlyLatest
boolStart 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
bootstrapServer
stringThe Apache Kafka bootstrap.servers
topicName
stringThe topic containing the data
cb
Action<object, Exception>The Action<T1, T2> where data will be available
token
CancellationTokenThe CancellationToken to use to stop execution
onlyLatest
boolStart 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
consumerConfig
ConsumerConfigBuilderThe ConsumerConfigBuilder with configuration
topicName
stringThe topic containing the data
cb
Action<TEntity, Exception>The Action<T1, T2> where data will be available
token
CancellationTokenThe CancellationToken to use to stop execution
onlyLatest
boolStart execution only for newest messages and does not execute for oldest, default is from beginning
Type Parameters
TEntity
The 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
bootstrapServer
stringThe Apache Kafka bootstrap.servers
topicName
stringThe topic containing the data
cb
Action<TEntity, Exception>The Action<T1, T2> where data will be available
token
CancellationTokenThe CancellationToken to use to stop execution
onlyLatest
boolStart execution only for newest messages and does not execute for oldest, default is from beginning
Type Parameters
TEntity
The Entity type if it is known