Skip to main content

Synapse - UnambitiousFx

Synapse is a simple Native-AOT mediator

dotnet add package UnambitiousFx.Synapse
Quick start
// 1 · Register
services.AddSynapse(cfg =>
    cfg.RegisterRequestHandler<
        CreateTaskHandler,
        CreateTaskCommand, Guid>());

// 2 · Define
public record CreateTaskCommand(string Title)
    : IRequest<Guid>;

public class CreateTaskHandler
    : IRequestHandler<CreateTaskCommand, Guid>
{
    public ValueTask<Result<Guid>> HandleAsync(
        CreateTaskCommand cmd, CancellationToken ct)
    {
        var id = Guid.NewGuid();
        return ValueTask.FromResult(Result.Success(id));
    }
}

// 3 · Invoke
var result = await invoker.InvokeAsync(
    new CreateTaskCommand("Buy milk"), ct);

result.Match(
    success: id    => Ok(id),
    failure: error => BadRequest(error.ToString()));

Why Synapse?

Mediator Pattern

Decouple with Commands, Queries, and Events. Each message has one focused handler — no hidden dependencies, no service locator.

🔗

Composable Pipelines

Attach validation, logging, retries, and metrics as pluggable pipeline behaviors — zero changes to your handlers.

🚀

Performance First

ValueTask-based APIs and minimal allocations in hot paths. Native AOT support keeps latency low at any message volume.

🔒

Zero Runtime Reflection

Dispatch delegates compile at DI registration time — no MakeGenericType at request time. Safe for trimming and NativeAOT.