Class KEFCoreOptionsExtension
- Namespace
- MASES.EntityFrameworkCore.KNet.Infrastructure.Internal
- Assembly
- MASES.EntityFrameworkCore.KNet.dll
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public class KEFCoreOptionsExtension : IDbContextOptionsExtension, IKEFCoreSingletonOptions, ISingletonOptions
- Inheritance
-
KEFCoreOptionsExtension
- Implements
- Inherited Members
- Extension Methods
Constructors
KEFCoreOptionsExtension()
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public KEFCoreOptionsExtension()
KEFCoreOptionsExtension(KEFCoreOptionsExtension)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
protected KEFCoreOptionsExtension(KEFCoreOptionsExtension copyFrom)
Parameters
copyFromKEFCoreOptionsExtension
Properties
ApplicationId
The application id associated to the application in use, shall be set if UseCompactedReplicator is false
public virtual string? ApplicationId { get; set; }
Property Value
Remarks
Choose the value carefully: upon restart its value is used to identify information on Apache Kafka� cluster of previous running application. If UseGlobalTable is false the partitions associated to each topic are shared across all instances with the same ApplicationId so be carefull to avoid other application consumes the data from Apache Kafka� cluster and local stores does not contains the expected information.
BootstrapServers
The bootstrap servers of the Apache Kafka� cluster
public virtual string? BootstrapServers { get; set; }
Property Value
ClusterId
Internal property
public virtual string ClusterId { get; }
Property Value
ConsumerConfig
The optional ConsumerConfigBuilder used when UseCompactedReplicator is true
[Obsolete("Option will be removed soon")]
public virtual ConsumerConfigBuilder? ConsumerConfig { get; set; }
Property Value
DefaultConsumerInstances
Default consumr instances used in conjunction with UseCompactedReplicator
[Obsolete("Option will be removed soon")]
public virtual int? DefaultConsumerInstances { get; set; }
Property Value
- int?
DefaultNumPartitions
Default number of partitions associated to each topic
public virtual int DefaultNumPartitions { get; set; }
Property Value
DefaultReplicationFactor
Default replication factor associated to each topic
public virtual short DefaultReplicationFactor { get; set; }
Property Value
DefaultSynchronizationTimeout
The default timeout, expressed in milliseconds, KEFCore will wait for backend to be in-sync with Apache Kafka� cluster.
Setting DefaultSynchronizationTimeout to 0 the synchronization will be disabled
public virtual long DefaultSynchronizationTimeout { get; set; }
Property Value
Remarks
The KEFCore provider try to synchronize with Apache Kafka� cluster waiting at least DefaultSynchronizationTimeout when EnsureCreated() of Database is invoked.
Info
Information/metadata about the extension.
public virtual DbContextOptionsExtensionInfo Info { get; }
Property Value
KeySerDesSelectorType
The optional Type to use for key serialization selection
Default value is DefaultKEFCoreSerDes.Key<T>, any custom Type shall implement ISerDesSelector<T>
public virtual Type KeySerDesSelectorType { get; set; }
Property Value
ProducerConfig
The optional ProducerConfigBuilder
public virtual ProducerConfigBuilder? ProducerConfig { get; set; }
Property Value
ReadOnlyMode
Setting this property to true if the engine shall reject any write operation, its value will be used to verify if topics has the proper rights WRITE and READ
public virtual bool ReadOnlyMode { get; set; }
Property Value
SaslConfig
SASL configuration applied to all Kafka clients (producer, streams). When set, it is merged into ProducerConfig and StreamsConfig at connection time via WithSaslConfigs(SaslConfigsBuilder).
public virtual SaslConfigsBuilder? SaslConfig { get; set; }
Property Value
SecurityProtocol
SecurityProtocol configuration applied to all Kafka clients (producer, streams). When set, it is merged into ProducerConfig and StreamsConfig at connection time via WithSecurityProtocol(string).
public virtual SecurityProtocol? SecurityProtocol { get; set; }
Property Value
SslConfig
SSL configuration applied to all Kafka clients (producer, streams). When set, it is merged into ProducerConfig and StreamsConfig at connection time via WithSslConfigs(SslConfigsBuilder).
public virtual SslConfigsBuilder? SslConfig { get; set; }
Property Value
StreamsConfig
The optional StreamsConfig used when UseCompactedReplicator is false
public virtual StreamsConfigBuilder? StreamsConfig { get; set; }
Property Value
TopicConfig
The optional TopicConfigBuilder used when topics shall be created
public virtual TopicConfigBuilder? TopicConfig { get; set; }
Property Value
UseCompactedReplicator
Use KNetCompactedReplicator<K, V> instead of Apache Kafka� Streams
[Obsolete("Option will be removed soon")]
public virtual bool UseCompactedReplicator { get; set; }
Property Value
UseDeletePolicyForTopic
Use delete cleanup policy when a topic is created
public virtual bool UseDeletePolicyForTopic { get; set; }
Property Value
UseEnumeratorWithPrefetch
Setting this property to true the engine prefers to use enumerator instances able to do a prefetch on data speeding up execution
public virtual bool UseEnumeratorWithPrefetch { get; set; }
Property Value
Remarks
Used only if UseCompactedReplicator is false and UseKNetStreams is true, not available in EFCore 6.
UseGlobalTable
Setting this property to true the engine based on Streams (i.e. UseCompactedReplicator is false) will use GlobalKTable<K, V> (GlobalKTable<K, V, TJVMK, TJVMV> if UseKNetStreams is true) instead of KTable<K, V> (KTable<K, V, TJVMK, TJVMV> if UseKNetStreams is true) to manage local storage of information.
[Obsolete("ApplicationId must be unique per process — UseGlobalTable is no longer needed.")]
public virtual bool UseGlobalTable { get; set; }
Property Value
Remarks
Setting UseGlobalTable to true is in contrast with ManageEvents that needs UseCompactedReplicator=true or a backend based on KTable<K, V> (KTable<K, V, TJVMK, TJVMV> if UseKNetStreams is true) The behavior can be changed if the application based on KEFCore does not needs events (ManageEvents=true) and/or there is a limitation using KTable<K, V> (KTable<K, V, TJVMK, TJVMV> if UseKNetStreams is true) coming from other configuration parameters like ApplicationId: using the same ApplicationId across the same cluster, the partitions of KTable<K, V> (KTable<K, V, TJVMK, TJVMV> if UseKNetStreams is true) are managed from multiple instances.
UseKNetStreams
Use KNet version of Apache Kafka� Streams instead of standard Apache Kafka� Streams
public virtual bool UseKNetStreams { get; set; }
Property Value
UseKeyByteBufferDataTransfer
Setting this property to true the engine prefers to use ByteBuffer data exchange in serializer instances for the key
public virtual bool UseKeyByteBufferDataTransfer { get; set; }
Property Value
UsePersistentStorage
Use persistent storage when Apache Kafka� Streams is in use
public virtual bool UsePersistentStorage { get; set; }
Property Value
UseStoreKeyRange
Setting this property to true to enable key range look-up in engine
public virtual bool UseStoreKeyRange { get; }
Property Value
UseStorePrefixScan
Setting this property to true to enable prefix scan in engine
public virtual bool UseStorePrefixScan { get; set; }
Property Value
UseStoreReverse
Setting this property to true to enable reverse look-up in engine
public virtual bool UseStoreReverse { get; }
Property Value
UseStoreReverseKeyRange
Setting this property to true to enable reverse key range look-up in engine
public virtual bool UseStoreReverseKeyRange { get; }
Property Value
UseStoreSingleKeyLookup
Setting this property to true to enable single key look-up in engine
public virtual bool UseStoreSingleKeyLookup { get; }
Property Value
UseValueContainerByteBufferDataTransfer
Setting this property to true the engine prefers to use ByteBuffer data exchange in serializer instances for value buffer
public virtual bool UseValueContainerByteBufferDataTransfer { get; set; }
Property Value
ValueContainerType
The optional Type to use as value container
Default value is DefaultValueContainer<TKey>, any custom Type shall implement IValueContainer<T>
public virtual Type ValueContainerType { get; set; }
Property Value
ValueSerDesSelectorType
The optional Type to use for value serialization selection
Default value is DefaultKEFCoreSerDes.ValueContainer<T>, any custom Type shall implement ISerDesSelector<T>
public virtual Type ValueSerDesSelectorType { get; set; }
Property Value
Methods
ApplyServices(IServiceCollection)
Adds the services required to make the selected options work. This is used when there is no external IServiceProvider and EF is maintaining its own service provider internally. This allows database providers (and other extensions) to register their required services when EF is creating an service provider.
public virtual void ApplyServices(IServiceCollection services)
Parameters
servicesIServiceCollectionThe collection to add services to.
Clone()
protected virtual KEFCoreOptionsExtension Clone()
Returns
ConsumerOptionsBuilder()
Build ConsumerConfigBuilder for producers
public virtual ConsumerConfigBuilder ConsumerOptionsBuilder()
Returns
Initialize(IDbContextOptions)
Initializes the singleton options from the given IDbContextOptions.
public void Initialize(IDbContextOptions options)
Parameters
optionsIDbContextOptions
ProducerOptions()
Build Properties for producers
public virtual Properties ProducerOptions()
Returns
ProducerOptionsBuilder()
Build ProducerConfigBuilder for producers
public virtual ProducerConfigBuilder ProducerOptionsBuilder()
Returns
StreamsOptions()
Build StreamsConfigBuilder from options
public virtual StreamsConfigBuilder StreamsOptions()
Returns
StreamsOptions(string)
Build Properties for applicationId
public virtual Properties StreamsOptions(string applicationId)
Parameters
applicationIdstring
Returns
Validate(IDbContextOptions)
Gives the extension a chance to validate that all options in the extension are valid. Most extensions do not have invalid combinations and so this will be a no-op. If options are invalid, then an exception should be thrown.
public virtual void Validate(IDbContextOptions options)
Parameters
optionsIDbContextOptionsThe options being validated.
WithApplicationId(string?)
The application id associated to the application in use, shall be set if UseCompactedReplicator is false
public virtual KEFCoreOptionsExtension WithApplicationId(string? applicationId)
Parameters
applicationIdstring
Returns
Remarks
Choose the value carefully: upon restart its value is used to identify information on Apache Kafka� cluster of previous running application. If UseGlobalTable is false the partitions associated to each topic are shared across all instances with the same ApplicationId so be carefull to avoid other application consumes the data from Apache Kafka� cluster and local stores does not contains the expected information.
WithBootstrapServers(string)
The bootstrap servers of the Apache Kafka� cluster
public virtual KEFCoreOptionsExtension WithBootstrapServers(string bootstrapServers)
Parameters
bootstrapServersstring
Returns
WithCompactedReplicator(bool)
Use KNetCompactedReplicator<K, V> instead of Apache Kafka� Streams
[Obsolete("Option will be removed soon")]
public virtual KEFCoreOptionsExtension WithCompactedReplicator(bool useCompactedReplicator = true)
Parameters
useCompactedReplicatorbool
Returns
WithConsumerConfig(ConsumerConfigBuilder)
The optional ConsumerConfigBuilder used when UseCompactedReplicator is true
[Obsolete("Option will be removed soon")]
public virtual KEFCoreOptionsExtension WithConsumerConfig(ConsumerConfigBuilder consumerConfigBuilder)
Parameters
consumerConfigBuilderConsumerConfigBuilder
Returns
WithDefaultConsumerInstances(int?)
Default consumr instances used in conjunction with UseCompactedReplicator
[Obsolete("Option will be removed soon")]
public virtual KEFCoreOptionsExtension WithDefaultConsumerInstances(int? defaultConsumerInstances = null)
Parameters
defaultConsumerInstancesint?
Returns
WithDefaultNumPartitions(int)
Default number of partitions associated to each topic
public virtual KEFCoreOptionsExtension WithDefaultNumPartitions(int defaultNumPartitions = 1)
Parameters
defaultNumPartitionsint
Returns
WithDefaultReplicationFactor(short)
Default replication factor associated to each topic
public virtual KEFCoreOptionsExtension WithDefaultReplicationFactor(short defaultReplicationFactor = 3)
Parameters
defaultReplicationFactorshort
Returns
WithDefaultSynchronizationTimeout(long)
The default timeout, expressed in milliseconds, KEFCore will wait for backend to be in-sync with Apache Kafka� cluster.
Setting DefaultSynchronizationTimeout to 0 the synchronization will be disabled
public virtual KEFCoreOptionsExtension WithDefaultSynchronizationTimeout(long defaultSynchronizationTimeout)
Parameters
defaultSynchronizationTimeoutlong
Returns
Remarks
The KEFCore provider try to synchronize with Apache Kafka� cluster waiting at least DefaultSynchronizationTimeout when EnsureCreated() of Database is invoked.
WithDeletePolicyForTopic(bool)
Use delete cleanup policy when a topic is created
public virtual KEFCoreOptionsExtension WithDeletePolicyForTopic(bool useDeletePolicyForTopic = true)
Parameters
useDeletePolicyForTopicbool
Returns
WithEnumeratorWithPrefetch(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 KEFCoreOptionsExtension WithEnumeratorWithPrefetch(bool useEnumeratorWithPrefetch = true)
Parameters
useEnumeratorWithPrefetchbool
Returns
Remarks
Used only if UseCompactedReplicator is false and UseKNetStreams is true, not available in EFCore 6.
WithGlobalTable(bool)
Setting this property to true the engine based on Streams (i.e. UseCompactedReplicator is false) will use GlobalKTable<K, V> (GlobalKTable<K, V, TJVMK, TJVMV> if UseKNetStreams is true) instead of KTable<K, V> (KTable<K, V, TJVMK, TJVMV> if UseKNetStreams is true) to manage local storage of information.
[Obsolete("ApplicationId must be unique per process — UseGlobalTable is no longer needed.")]
public virtual KEFCoreOptionsExtension WithGlobalTable(bool useGlobalTable = true)
Parameters
useGlobalTablebool
Returns
Remarks
Setting UseGlobalTable to true is in contrast with ManageEvents that needs UseCompactedReplicator=true or a backend based on KTable<K, V> (KTable<K, V, TJVMK, TJVMV> if UseKNetStreams is true) The behavior can be changed if the application based on KEFCore does not needs events (ManageEvents=true) and/or there is a limitation using KTable<K, V> (KTable<K, V, TJVMK, TJVMV> if UseKNetStreams is true) coming from other configuration parameters like ApplicationId: using the same ApplicationId across the same cluster, the partitions of KTable<K, V> (KTable<K, V, TJVMK, TJVMV> if UseKNetStreams is true) are managed from multiple instances.
WithKNetStreams(bool)
Use KNet version of Apache Kafka� Streams instead of standard Apache Kafka� Streams
public virtual KEFCoreOptionsExtension WithKNetStreams(bool useKNetStreams = true)
Parameters
useKNetStreamsbool
Returns
WithKeyByteBufferDataTransfer(bool)
Setting this property to true the engine prefers to use ByteBuffer data exchange in serializer instances for the key
public virtual KEFCoreOptionsExtension WithKeyByteBufferDataTransfer(bool useKeyByteBufferDataTransfer = true)
Parameters
useKeyByteBufferDataTransferbool
Returns
WithKeySerDesSelectorType(Type)
The optional Type to use for key serialization selection
Default value is DefaultKEFCoreSerDes.Key<T>, any custom Type shall implement ISerDesSelector<T>
public virtual KEFCoreOptionsExtension WithKeySerDesSelectorType(Type serializationType)
Parameters
serializationTypeType
Returns
WithPersistentStorage(bool)
Use persistent storage when Apache Kafka� Streams is in use
public virtual KEFCoreOptionsExtension WithPersistentStorage(bool usePersistentStorage = true)
Parameters
usePersistentStoragebool
Returns
WithProducerConfig(ProducerConfigBuilder)
The optional ProducerConfigBuilder
public virtual KEFCoreOptionsExtension WithProducerConfig(ProducerConfigBuilder producerConfigBuilder)
Parameters
producerConfigBuilderProducerConfigBuilder
Returns
WithReadOnlyMode(bool)
Setting this property to true if the engine shall reject any write operation, its value will be used to verify if topics has the proper rights WRITE and READ
public virtual KEFCoreOptionsExtension WithReadOnlyMode(bool readOnlyMode)
Parameters
readOnlyModebool
Returns
WithSaslConfig(SaslConfigsBuilder)
SASL configuration applied to all Kafka clients (producer, streams). When set, it is merged into ProducerConfig and StreamsConfig at connection time via WithSaslConfigs(SaslConfigsBuilder).
public virtual KEFCoreOptionsExtension WithSaslConfig(SaslConfigsBuilder saslConfigsBuilder)
Parameters
saslConfigsBuilderSaslConfigsBuilder
Returns
WithSecurityProtocol(SecurityProtocol)
SecurityProtocol configuration applied to all Kafka clients (producer, streams). When set, it is merged into ProducerConfig and StreamsConfig at connection time via WithSecurityProtocol(string).
public virtual KEFCoreOptionsExtension WithSecurityProtocol(SecurityProtocol securityProtocol)
Parameters
securityProtocolSecurityProtocol
Returns
WithSslConfig(SslConfigsBuilder)
SSL configuration applied to all Kafka clients (producer, streams). When set, it is merged into ProducerConfig and StreamsConfig at connection time via WithSslConfigs(SslConfigsBuilder).
public virtual KEFCoreOptionsExtension WithSslConfig(SslConfigsBuilder sslConfigsBuilder)
Parameters
sslConfigsBuilderSslConfigsBuilder
Returns
WithStoreKeyRange(bool)
Setting this property to true to enable key range look-up in engine
public virtual KEFCoreOptionsExtension WithStoreKeyRange(bool enabled = true)
Parameters
enabledbool
Returns
WithStorePrefixScan(bool)
Setting this property to true to enable prefix scan in engine
public virtual KEFCoreOptionsExtension WithStorePrefixScan(bool enabled = true)
Parameters
enabledbool
Returns
WithStoreReverse(bool)
Setting this property to true to enable reverse look-up in engine
public virtual KEFCoreOptionsExtension WithStoreReverse(bool enabled = true)
Parameters
enabledbool
Returns
WithStoreReverseKeyRange(bool)
Setting this property to true to enable reverse key range look-up in engine
public virtual KEFCoreOptionsExtension WithStoreReverseKeyRange(bool enabled = true)
Parameters
enabledbool
Returns
WithStoreSingleKeyLookup(bool)
Setting this property to true to enable single key look-up in engine
public virtual KEFCoreOptionsExtension WithStoreSingleKeyLookup(bool enabled = true)
Parameters
enabledbool
Returns
WithStreamsConfig(StreamsConfigBuilder)
The optional StreamsConfig used when UseCompactedReplicator is false
public virtual KEFCoreOptionsExtension WithStreamsConfig(StreamsConfigBuilder streamsConfigBuilder)
Parameters
streamsConfigBuilderStreamsConfigBuilder
Returns
WithTopicConfig(TopicConfigBuilder)
The optional TopicConfigBuilder used when topics shall be created
public virtual KEFCoreOptionsExtension WithTopicConfig(TopicConfigBuilder topicConfigBuilder)
Parameters
topicConfigBuilderTopicConfigBuilder
Returns
WithValueContainerByteBufferDataTransfer(bool)
Setting this property to true the engine prefers to use ByteBuffer data exchange in serializer instances for value buffer
public virtual KEFCoreOptionsExtension WithValueContainerByteBufferDataTransfer(bool useValueContainerByteBufferDataTransfer = true)
Parameters
useValueContainerByteBufferDataTransferbool
Returns
WithValueContainerType(Type)
The optional Type to use as value container
Default value is DefaultValueContainer<TKey>, any custom Type shall implement IValueContainer<T>
public virtual KEFCoreOptionsExtension WithValueContainerType(Type serializationType)
Parameters
serializationTypeType
Returns
WithValueSerDesSelectorType(Type)
The optional Type to use for value serialization selection
Default value is DefaultKEFCoreSerDes.ValueContainer<T>, any custom Type shall implement ISerDesSelector<T>
public virtual KEFCoreOptionsExtension WithValueSerDesSelectorType(Type serializationType)
Parameters
serializationTypeType