Example #1
0
        public PostgresReplicationSubscriber(PostgresConfiguration postgresConfiguration)
        {
            _config = postgresConfiguration ?? throw new ArgumentNullException(nameof(postgresConfiguration));

            if (string.IsNullOrWhiteSpace(_config.ConnectionString))
            {
                throw new ArgumentNullException(nameof(_config.ConnectionString));
            }
            if (string.IsNullOrWhiteSpace(_config.PublicationName))
            {
                throw new ArgumentNullException(nameof(_config.PublicationName));
            }
            if (string.IsNullOrWhiteSpace(_config.ReplicationSlotName))
            {
                throw new ArgumentNullException(nameof(_config.ReplicationSlotName));
            }

            _connection = new LogicalReplicationConnection(_config.ConnectionString);
            _           = StartAsync();
        }
Example #2
0
 public static IServiceCollection AddDotNetifyPostgres(this IServiceCollection services, PostgresConfiguration config)
 {
     services.AddSingleton(config);
     services.AddSingleton <IPostgresReplicationSubscriber, PostgresReplicationSubscriber>();
     services.AddSingleton <IDbChangeObserver, DbChangeObserver>();
     return(services);
 }