Class KafkaDbContextOptionsBuilder
- Namespace
- MASES.EntityFrameworkCore.KNet.Infrastructure
- Assembly
- MASES.EntityFrameworkCore.KNet.dll
Allows Kafka specific configuration to be performed on DbContextOptions.
public class KafkaDbContextOptionsBuilder : IKafkaDbContextOptionsBuilderInfrastructure
- Inheritance
-
KafkaDbContextOptionsBuilder
- Implements
- Inherited Members
Remarks
Instances of this class are returned from a call to UseKafkaCluster(DbContextOptionsBuilder, string, string, string, Action<KafkaDbContextOptionsBuilder>?) and it is not designed to be directly constructed in your application code.
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
Constructors
KafkaDbContextOptionsBuilder(DbContextOptionsBuilder)
Initializes a new instance of the KafkaDbContextOptionsBuilder class.
public KafkaDbContextOptionsBuilder(DbContextOptionsBuilder optionsBuilder)
Parameters
optionsBuilder
DbContextOptionsBuilderThe options builder.
Properties
OptionsBuilder
Clones the configuration in this builder.
protected virtual DbContextOptionsBuilder OptionsBuilder { get; }
Property Value
- DbContextOptionsBuilder
The cloned configuration.
Methods
WithCompactedReplicator(bool)
Enables use of KNetCompactedReplicator<K, V>
public virtual KafkaDbContextOptionsBuilder WithCompactedReplicator(bool useCompactedReplicator = false)
Parameters
useCompactedReplicator
boolIf true then KNetCompactedReplicator<K, V> will be used instead of Apache Kafka Streams.
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithConsumerConfig(ConsumerConfigBuilder)
Set properties of KNetCompactedReplicator<K, V>.
public virtual KafkaDbContextOptionsBuilder WithConsumerConfig(ConsumerConfigBuilder consumerConfigBuilder)
Parameters
consumerConfigBuilder
ConsumerConfigBuilderThe ConsumerConfigBuilder where options are stored.
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithDefaultConsumerInstances(int?)
Defines the default number of consumer instances to be used in conjunction with WithCompactedReplicator(bool)
public virtual KafkaDbContextOptionsBuilder WithDefaultConsumerInstances(int? defaultConsumerInstances = null)
Parameters
defaultConsumerInstances
int?The default number of consumer instances to be used in conjunction with WithCompactedReplicator(bool)
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithDefaultNumPartitions(int)
Defines the default number of partitions to use when a new topic is created
public virtual KafkaDbContextOptionsBuilder WithDefaultNumPartitions(int defaultNumPartitions = 1)
Parameters
defaultNumPartitions
intThe default number of partitions to use when a new topic is created.
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithDefaultReplicationFactor(short)
Defines the default replication factor to use when a new topic is created
public virtual KafkaDbContextOptionsBuilder WithDefaultReplicationFactor(short defaultReplicationFactor = 1)
Parameters
defaultReplicationFactor
shortThe default replication factor to use when a new topic is created.
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithKeySerDesSelectorType(Type)
Define the external serialization Type for key
public virtual KafkaDbContextOptionsBuilder WithKeySerDesSelectorType(Type serializationType)
Parameters
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithOnChangeEvent(Action<EntityTypeChanged>)
Set the optional handler to be used to receive notification when the back-end triggers a data change. Works if WithCompactedReplicator(bool) is invoked with true
public virtual KafkaDbContextOptionsBuilder WithOnChangeEvent(Action<EntityTypeChanged> onChangeEvent)
Parameters
onChangeEvent
Action<EntityTypeChanged>The Action<T1, T2, T3> will be used to report change event.
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithProducerConfig(ProducerConfigBuilder)
Set properties of KafkaProducer.
public virtual KafkaDbContextOptionsBuilder WithProducerConfig(ProducerConfigBuilder producerConfigBuilder)
Parameters
producerConfigBuilder
ProducerConfigBuilderThe ProducerConfigBuilder where options are stored.
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithStreamsConfig(StreamsConfigBuilder)
Set properties of KafkaStreams.
public virtual KafkaDbContextOptionsBuilder WithStreamsConfig(StreamsConfigBuilder streamsConfigBuilder)
Parameters
streamsConfigBuilder
StreamsConfigBuilderThe StreamsConfigBuilder where options are stored.
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithTopicConfig(TopicConfigBuilder)
Set properties of TopicConfig.
public virtual KafkaDbContextOptionsBuilder WithTopicConfig(TopicConfigBuilder topicConfig)
Parameters
topicConfig
TopicConfigBuilderThe TopicConfigBuilder where options are stored.
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithUseByteBufferDataTransfer(bool)
Setting this property to true the engine prefers to use ByteBuffer data exchange in serializer instances
public virtual KafkaDbContextOptionsBuilder WithUseByteBufferDataTransfer(bool useByteBufferDataTransfer = true)
Parameters
useByteBufferDataTransfer
boolIf true, ByteBuffer data exchange will be preferred.
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithUseDeletePolicyForTopic(bool)
Enables delete cleanup policy when the topic is created the first time
public virtual KafkaDbContextOptionsBuilder WithUseDeletePolicyForTopic(bool useDeletePolicyForTopic = false)
Parameters
useDeletePolicyForTopic
boolIf true, then will be used delete cleanup policy when the topic is created the first time.
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithUseEnumeratorWithPrefetch(bool)
Setting this property to true the engine prefers to use enumerator instances able to do a prefetch on data speeding up execution
public virtual KafkaDbContextOptionsBuilder WithUseEnumeratorWithPrefetch(bool useEnumeratorWithPrefetch = true)
Parameters
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
Used only if UseCompactedReplicator is false and UseKNetStreams is true, not available in EFCore 6 See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithUseKNetStreams(bool)
Enables use of KNet version of Apache Kafka Streams
public virtual KafkaDbContextOptionsBuilder WithUseKNetStreams(bool useKNetStreams = false)
Parameters
useKNetStreams
boolIf true then KNet version of Apache Kafka Streams will be used instead of standard Apache Kafka Streams.
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithUseNameMatching(bool)
Enables name matching on IEntityType instead of Type matching
public virtual KafkaDbContextOptionsBuilder WithUseNameMatching(bool useNameMatching = true)
Parameters
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithUsePersistentStorage(bool)
Setting this property to true the engine prefers to use enumerator instances able to do a prefetch on data speeding up execution
public virtual KafkaDbContextOptionsBuilder WithUsePersistentStorage(bool usePersistentStorage = false)
Parameters
usePersistentStorage
boolIf true the engine prefers to use enumerator instances able to do a prefetch on data speeding up execution
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
Used only if UseCompactedReplicator is false and UseKNetStreams is true, not available in EFCore 6. See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithValueContainerType(Type)
Define the external Type which contains the values
public virtual KafkaDbContextOptionsBuilder WithValueContainerType(Type serializationType)
Parameters
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.
WithValueSerDesSelectorType(Type)
Define the external serialization Type for value
public virtual KafkaDbContextOptionsBuilder WithValueSerDesSelectorType(Type serializationType)
Parameters
Returns
- KafkaDbContextOptionsBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.