PulseSharp.Testing
0.8.0-alpha
Prefix Reserved
dotnet add package PulseSharp.Testing --version 0.8.0-alpha
NuGet\Install-Package PulseSharp.Testing -Version 0.8.0-alpha
<PackageReference Include="PulseSharp.Testing" Version="0.8.0-alpha" />
<PackageVersion Include="PulseSharp.Testing" Version="0.8.0-alpha" />
<PackageReference Include="PulseSharp.Testing" />
paket add PulseSharp.Testing --version 0.8.0-alpha
#r "nuget: PulseSharp.Testing, 0.8.0-alpha"
#:package PulseSharp.Testing@0.8.0-alpha
#addin nuget:?package=PulseSharp.Testing&version=0.8.0-alpha&prerelease
#tool nuget:?package=PulseSharp.Testing&version=0.8.0-alpha&prerelease
Status: preview (
0.8). Events and jobs work with the SQLite and PostgreSQL stores, and devices sync their events with a server. See the roadmap. The API may change before1.0.
What is PulseSharp?
PulseSharp is a small .NET library for durable events and background jobs.
- Events: something happened (
SaleCompleted). PulseSharp saves the event first, then delivers it to every handler, in order, with retries. - Jobs: work to do (
ImportProducts). PulseSharp saves the job, runs it once, and reports progress. Jobs can be retried and cancelled.
It works the same way in a desktop app, a web app, a worker service or a console app, and on the database you already have.
A quick look
dotnet add package PulseSharp.Sqlite --prerelease
public sealed record SaleCompleted(Guid SaleId, decimal Total);
public sealed record SendReceipt(Guid SaleId);
// Setup: the store, plus what should happen
builder.Services.AddPulseSharp(pulse =>
{
pulse.UseSqlite("app.db");
pulse.On<SaleCompleted>("sales-log", (sale, context, ct) =>
{
Console.WriteLine($"Sold for {sale.Total}");
return Task.CompletedTask;
});
pulse.OnJob<SendReceipt>(async (receipt, context, ct) => await mailer.SendReceipt(receipt.SaleId, ct));
});
// Something happened: emit it from anywhere through IPulse
await pulse.Emit(new SaleCompleted(sale.Id, sale.Total));
// Work to do: now, or later
await pulse.Enqueue(new SendReceipt(sale.Id));
await pulse.EnqueueIn(new SendReceipt(sale.Id), TimeSpan.FromMinutes(5));
That is all most apps need. When you need more, it is there: named handlers and handler classes from dependency injection, a stream per item (pulse.Emit("Sale-" + id, sale)), expected versions, your own database transaction, job progress and cancel, and IPulseControl to retry, skip or rewind. The docs start simple and go deeper step by step.
PulseSharp runs as a hosted service, so it works in any app that uses the .NET Generic Host: web apps, worker services, and desktop apps that build a host.
What you get today
Events of one stream reach each handler in order. Different streams and different handlers are independent.
A failing handler is retried with a growing delay. After
MaxAttemptsits stream stops for that handler only, and everything else keeps flowing.Stable names: duplicate handler names or event names stop the app at startup with a clear message.
Optimistic concurrency with
EmitOptions.ExpectedVersion.Every event gets a time-ordered, globally unique id (UUIDv7) and records the node that emitted it.
Several streams in parallel per handler (
Advanced.MaxParallelStreams, default 8), still in order within each stream.Fast delivery: a handler saves its progress in groups (at most 100 events or 200 ms of progress is ever repeated after a crash), so a backlog is handled at many thousands of events per second on SQLite and PostgreSQL.
Healing: a handler or job that hangs is stopped after
Advanced.HandlerTimeout/JobTimeoutand retried; after a crash, handlers are taken over within 10 seconds and running jobs within 30.EmitAll: several events in one commit, all or none, in the order given, and much faster than emitting them one by one.IPulseControl: list the cursors of every handler, retry or skip a failed event, retry every failed stream at once (RetryFailed), or rewind a handler to handle everything again.Handler classes from dependency injection:
AddHandler<TEvent, THandler>()andAddJobHandler<TJob, THandler>(), or inline withOnandOnJob. All of them work with trimming and Native AOT.SQLite store:
pulse.UseSqlite("app.db")(packagePulseSharp.Sqlite). Events, cursors and jobs survive a restart; your ownSqliteTransactionsaves data and events together.PostgreSQL store:
pulse.UsePostgreSql(connectionString)(packagePulseSharp.PostgreSql, schemapulsesharpby default). Run several app instances on one database: each handler is delivered by one instance at a time, jobs are claimed withSKIP LOCKED, andIPulseControlworks from any instance, and other instances hear about new work at once (LISTEN/NOTIFY).Jobs:
Enqueuenow,EnqueueIn/EnqueueAtlater, one handler per job type, retries with a growing delay, progress (context.Report), cancel (the handler's token),Advanced.MaxParallelJobs(default 4), finished jobs cleaned up after 7 days (Advanced.KeepFinishedJobs), and leases so a job left behind by a stopped app instance runs again.IPulseControlreads, lists, cancels and retries jobs.Device to cloud sync:
pulse.UseSync(sync => …)with the server address and key on the device (packagePulseSharp.Sync),pulse.UseSyncServer(server => server.AllowNode("till-1", key).PushStreams(node => [$"Sale-{node}-"]))andapp.MapPulseSharpSync()on the server (packagePulseSharp.Sync.Server). The device works offline; when online it sends its own events and receives the server's. No duplicates, no echoes, resumable batches, and the server decides which streams each device may receive and which it may write.Testing:
PulseSharp.Testingfor your test projects: give your code aFakePulse, then checkpulse.Emitted<SaleCompleted>(),pulse.NotEmitted<T>(),pulse.Enqueued(job); call handlers withhandler.Handle(event); run several handlers together withPulseTestHostandWaitUntilIdle().
See samples/ConsoleSample: a printer runs out of paper, the receipts fail, and IPulseControl retries them; then an end-of-day job reports its progress.
See samples/PosSync: two tills sell while the cloud is down, sync when it comes back, and receive a price change and an oversold warning from the cloud.
Performance
The engine on the in-memory test store, one machine, BenchmarkDotNet short run (benchmarks/):
| Per event | Time | Allocated |
|---|---|---|
| Emit (no handlers) | ~0.5 µs | 542 B |
| Emit + deliver to 1 handler | ~2.2 µs | 1.0 KB |
| Emit + deliver to 3 handlers | ~5.6 µs | 1.9 KB |
| Enqueue + run a job | ~21 µs | 4.5 KB |
| Emit to a SQLite file (pooled, fully durable) | ~0.66 ms | 5.7 KB |
| Emit to PostgreSQL (one round trip, local Docker) | ~2.0 ms | 6.2 KB |
Why PulseSharp?
- Lightweight. The contracts package has no dependencies. You add only the packages you use.
- Any database. SQLite and PostgreSQL first. Other stores plug into a small contract.
- Any app. No ASP.NET Core in the core packages. It works with Native AOT.
- Device to cloud. Events are saved on the device and keep working offline. They sync to the server when the device is back online.
- Honest guarantees. Delivery is at-least-once, and every handler sees each stream in order. The docs say exactly what is guaranteed and what is not.
Packages
| Package | What it adds | Status |
|---|---|---|
PulseSharp.Abstractions |
Contracts for handlers and libraries. No dependencies. | Preview |
PulseSharp |
The engine | Preview |
PulseSharp.Sqlite |
SQLite store, for desktop and mobile apps | Preview |
PulseSharp.PostgreSql |
PostgreSQL store, for servers and several app instances | Preview |
PulseSharp.Sync |
Device to cloud sync: the device side | Preview |
PulseSharp.Sync.Server |
Device to cloud sync: the ASP.NET Core endpoint | Preview |
PulseSharp.Testing |
Test helpers for your app: FakePulse, simple checks, an in-memory store, and a test host that waits until all work is done |
Preview |
PulseSharp.Monitor |
Optional web UI | Planned (after 1.0) |
Learn more
- 📖 Documentation: guides, concepts and the API reference
- Getting started: your first event and job in five minutes
- Vision and roadmap
- Contributing
License
| Product | Versions 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. |
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- PulseSharp (>= 0.8.0-alpha)
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 |
|---|---|---|
| 0.8.0-alpha | 71 | 10/31/2026 |
| 0.7.0-alpha | 89 | 10/24/2026 |
| 0.6.0-alpha | 74 | 10/20/2026 |