/// <summary>
        /// Configures Topos to use Kafkaesque and the file system as the event store
        /// </summary>
        public static void UseFileSystem(this StandardConfigurer <IConsumerImplementation> configurer, string directoryPath)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }

            CheckDirectoryPath(directoryPath);

            StandardConfigurer.Open(configurer).Register(c =>
            {
                var loggerFactory = c.Get <ILoggerFactory>();
                var topics        = c.Has <Topics>() ? c.Get <Topics>() : new Topics();
                var group         = c.Get <GroupId>();

                return(new KafkaesqueFileSystemConsumerImplementation(
                           directoryPath: directoryPath,
                           loggerFactory: loggerFactory,
                           topics: topics,
                           group.Id,
                           consumerDispatcher: c.Get <IConsumerDispatcher>(),
                           positionManager: c.Get <IPositionManager>()
                           ));
            });
        }
Ejemplo n.º 2
0
        public static KafkaProducerConfigurationBuilder UseKafka(this StandardConfigurer <IConsumerImplementation> configurer, IEnumerable <string> bootstrapServers)
        {
            var builder = new KafkaProducerConfigurationBuilder();

            StandardConfigurer.Open(configurer)
            .Register(c =>
            {
                var loggerFactory      = c.Get <ILoggerFactory>();
                var topics             = c.Has <Topics>() ? c.Get <Topics>() : new Topics();
                var group              = c.Get <GroupId>();
                var consumerDispatcher = c.Get <IConsumerDispatcher>();
                var positionManager    = c.Get <IPositionManager>(errorMessage: @"The Kafka consumer needs access to a positions manager, so it can figure out which offsets to pick up from when starting up.");

                return(new KafkaConsumerImplementation(
                           loggerFactory: loggerFactory,
                           address: string.Join("; ", bootstrapServers),
                           topics: topics,
                           group: group.Id,
                           consumerDispatcher: consumerDispatcher,
                           positionManager: positionManager
                           ));
            });

            return(builder);
        }
Ejemplo n.º 3
0
 public static void UseSerilog(this StandardConfigurer <ILoggerFactory> configurer)
 {
     if (configurer == null)
     {
         throw new ArgumentNullException(nameof(configurer));
     }
     StandardConfigurer.Open(configurer).Register(c => new SerilogLoggerFactory());
 }
Ejemplo n.º 4
0
        public static void UseNewtonsoftJson(this StandardConfigurer <IMessageSerializer> configurer, JsonSerializerSettings settings = null, Encoding encoding = null)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }

            StandardConfigurer.Open(configurer).Register(c => new JsonSerializer(settings: settings, encoding: encoding));
        }
        /// <summary>
        /// Configures Topos to use Kafkaesque and the file system as the event store
        /// </summary>
        public static void UseFileSystem(this StandardConfigurer <IProducerImplementation> configurer, string directoryPath)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }

            CheckDirectoryPath(directoryPath);

            StandardConfigurer.Open(configurer).Register(c => new KafkaesqueFileSystemProducerImplementation(directoryPath, c.Get <ILoggerFactory>()));
        }
Ejemplo n.º 6
0
        public static KafkaProducerConfigurationBuilder UseKafka(this StandardConfigurer <IProducerImplementation> configurer, IEnumerable <string> bootstrapServers)
        {
            var builder = new KafkaProducerConfigurationBuilder();

            StandardConfigurer.Open(configurer)
            .Register(c =>
            {
                var loggerFactory = c.Get <ILoggerFactory>();

                return(new KafkaProducerImplementation(loggerFactory, string.Join(";", bootstrapServers)));
            });

            return(builder);
        }
        public static void StoreInMongoDb(this StandardConfigurer <IPositionManager> configurer, IMongoDatabase database, string collectionName)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }
            if (database == null)
            {
                throw new ArgumentNullException(nameof(database));
            }
            if (collectionName == null)
            {
                throw new ArgumentNullException(nameof(collectionName));
            }

            var registrar = StandardConfigurer.Open(configurer);

            registrar.Register(c => new MongoDbPositionManager(database, collectionName));
        }
        public static void StoreInMemory(this StandardConfigurer <IPositionManager> configurer, InMemPositionsStorage positionsStorage = null)
        {
            var registrar = StandardConfigurer.Open(configurer);

            registrar.Register(c => new InMemPositionsManager(positionsStorage ?? new InMemPositionsStorage()));
        }