Publo.Postgres 1.0.1

dotnet add package Publo.Postgres --version 1.0.1
                    
NuGet\Install-Package Publo.Postgres -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Publo.Postgres" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Publo.Postgres" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Publo.Postgres" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Publo.Postgres --version 1.0.1
                    
#r "nuget: Publo.Postgres, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Publo.Postgres@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Publo.Postgres&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Publo.Postgres&version=1.0.1
                    
Install as a Cake Tool

Publo.Postgres

PostgreSQL provider for Publo broadcast events. It stores published events in PostgreSQL, runs migrations for the Publo schema, and starts a hosted runner that polls stored events and dispatches them to IPubloExecutor<T> handlers in each running pod or application instance.

Installation

dotnet add package Publo.Postgres

Registration

Register Publo with the PostgreSQL provider and supply an IConnectionFactory implementation:

using System.Data.Common;
using Npgsql;
using Publo.Abstraction.Extensions;
using Publo.Postgres.Extensions;
using Publo.Postgres.Infrastructure.Database;

builder.Services
    .AddPublo(publo => publo.UseNpgsql<ConnectionFactory>())
    .AddPubloExecutor<UserCreated, UserCreatedExecutor>();

public sealed class ConnectionFactory(IConfiguration configuration) : IConnectionFactory
{
    public string GetConnectionString()
        => configuration.GetConnectionString("Postgres")
           ?? throw new InvalidOperationException("Postgres connection string not found.");

    public Task<DbConnection> GetConnectionAsync(CancellationToken cancellationToken)
        => Task.FromResult<DbConnection>(new NpgsqlConnection(GetConnectionString()));
}

UseNpgsql<T> registers the provider, repository, migrations, options binding, and polling hosted service.

Use this provider when you want cluster-wide notifications without introducing Kafka. Each running instance can poll the PostgreSQL-backed event log and react locally to events such as cache invalidations, configuration refreshes, and other broadcast signals.

Configuration

UseNpgsql<T> binds options from the PostgresPubloOptions configuration section:

{
  "ConnectionStrings": {
    "Postgres": "Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=pwd;"
  },
  "PostgresPubloOptions": {
    "schemaName": "publo",
    "pollingInterval": "00:00:05",
    "offsetPolicy": "Latest"
  }
}

Options:

Name Default Description
SchemaName publo PostgreSQL schema used for Publo event tables and migration metadata.
PollingInterval 00:00:05 Delay between polling attempts after the current batch is drained.
OffsetPolicy Latest Controls where a new runner starts reading events.

OffsetPolicy.Latest starts from events created after the runner starts. OffsetPolicy.Earliest starts from the earliest uncommitted event available to the runner.

Publishing And Handling

using Publo.Abstraction.Executor;
using Publo.Abstraction.Services;

public sealed record UserCreated(Guid UserId);

public sealed class UserCreatedExecutor : IPubloExecutor<UserCreated>
{
    public Task HandleAsync(UserCreated message, CancellationToken cancellationToken)
    {
        // React to the broadcast event here.
        return Task.CompletedTask;
    }
}

public sealed class UsersService(IPubloService publo)
{
    public Task PublishAsync(Guid userId, CancellationToken cancellationToken)
        => publo.SendAsync(new UserCreated(userId), cancellationToken);
}

Local PostgreSQL

The repository docker-compose.yaml starts PostgreSQL on localhost:5432:

docker compose up -d postgres

Default local credentials are postgres / pwd, database postgres.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 152 6/6/2026
1.0.0 122 5/24/2026