Hugo 1.3.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Hugo --version 1.3.2
                    
NuGet\Install-Package Hugo -Version 1.3.2
                    
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="Hugo" Version="1.3.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Hugo" Version="1.3.2" />
                    
Directory.Packages.props
<PackageReference Include="Hugo" />
                    
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 Hugo --version 1.3.2
                    
#r "nuget: Hugo, 1.3.2"
                    
#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 Hugo@1.3.2
                    
#: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=Hugo&version=1.3.2
                    
Install as a Cake Addin
#tool nuget:?package=Hugo&version=1.3.2
                    
Install as a Cake Tool

Hugo

CI NuGet NuGet Diagnostics

Go-style concurrency primitives and functional result pipelines for .NET 9/10 applications.

Overview

Hugo brings Go-inspired building blocks—channels, wait groups, mutexes, timers, and defer—to the .NET runtime while embracing railway-oriented programming for error handling. The library ships with observability hooks, prioritised channels, and integration helpers designed to keep asynchronous code predictable, testable, and composable.

  • Structured docs: Tutorials, how-to guides, reference, and explanations live under docs/index.md.
  • Deterministic concurrency: WaitGroup, Mutex, RwMutex, and SelectAsync mirror Go semantics while honouring cancellation tokens and TimeProvider.
  • Functional results: Result<T> pipelines keep happy-path code linear and report failures with structured metadata.
  • Observability ready: GoDiagnostics exposes counters and histograms that plug straight into OpenTelemetry exporters.
  • Benchmarks & samples: benchmarks/Hugo.Benchmarks compares primitives under load; samples/Hugo.WorkerSample shows structured background work.

Compatibility

  • Targets net9.0 and net10.0.
  • Plays nicely with host builders, ASP.NET background services, and worker services.
  • Tested with the .NET 10 preview SDK; install alongside .NET 9 for full coverage.

Installation

dotnet add package Hugo
  • Works seamlessly with central package management (Directory.Packages.props).
  • To experiment locally, run dotnet pack src/Hugo/Hugo.csproj -o ./artifacts and reference the generated .nupkg from a local feed.

Quickstart

using Hugo;
using static Hugo.Go;

var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
var channel = MakeChannel<string>(capacity: 4);
var workers = new WaitGroup();

workers.Go(async () =>
{
    using var scope = Defer(() => channel.Writer.TryComplete());

    await channel.Writer.WriteAsync("hello", cts.Token);
    await channel.Writer.WriteAsync("world", cts.Token);
});

var messages = new List<string>();
while (await channel.Reader.WaitToReadAsync(cts.Token))
{
    if (channel.Reader.TryRead(out var value))
    {
        var result = Ok(value)
            .Ensure(static text => !string.IsNullOrWhiteSpace(text))
            .Map(static text => text.ToUpperInvariant());

        if (result.IsSuccess)
        {
            messages.Add(result.Value);
        }
    }
}

await workers.WaitAsync(cts.Token);
Console.WriteLine(string.Join(' ', messages));

Key Features

  • Go primitives for .NET: Wait groups, mutexes, RW locks, prioritized channels, deferred cleanup, and select-style coordination.
  • Railway-oriented results: Result<T> pipelines with Then, Map, Recover, Ensure, Tap, and friends for deterministic error handling.
  • Observability hooks: Metered counters and histograms via GoDiagnostics for wait-group activity, result creation, and channel select latency.
  • Cancellation-first design: All asynchronous APIs accept CancellationToken, wrap cancellations consistently, and surface Error.Canceled in pipelines.

Documentation

Samples & Benchmarks

  • samples/Hugo.WorkerSample: Background worker demonstrating task leasing with TaskQueue<T> plus wait groups and deferred cleanup.

Run the worker sample with a local OpenTelemetry collector

  1. Save the collector config below as otel-collector.yaml in the repository root:

    receivers:
        otlp:
            protocols:
                grpc:
                http:
    
    exporters:
        logging:
            loglevel: info
        prometheus:
            endpoint: "0.0.0.0:9464"
    
    service:
        pipelines:
            metrics:
                receivers: [otlp]
                exporters: [prometheus, logging]
            traces:
                receivers: [otlp]
                exporters: [logging]
    
  2. Start the collector (requires Docker):

    docker run --rm \
        -p 4317:4317 -p 4318:4318 -p 9464:9464 \
        -v "${PWD}/otel-collector.yaml:/etc/otelcol/config.yaml" \
        otel/opentelemetry-collector:0.103.1
    
  3. In a second terminal, run the worker sample:

    dotnet run --project samples/Hugo.WorkerSample/Hugo.WorkerSample.csproj
    
    • Override the collector endpoint with OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 if you change ports.
    • Disable Prometheus scraping with HUGO_PROMETHEUS_ENABLED=false when running without the Prometheus exporter.
  4. Inspect emitted metrics at http://localhost:9464/metrics and watch the collector logs for OTLP traces.

Benchmarks

The benchmarks/Hugo.Benchmarks directory contains a comprehensive BenchmarkDotNet suite comparing Hugo primitives against native .NET equivalents:

  • Mutex vs SemaphoreSlim: Lock acquisition and release performance
  • RwMutex: Read/write lock contention scenarios
  • Once: One-time initialization patterns
  • Pool: Object pooling efficiency
  • Channel factories: Bounded vs unbounded channel creation
  • Prioritized channels: Multi-level priority queue throughput
  • Result pipelines: Railway-oriented composition overhead
  • Select operations: Channel coordination latency

Run benchmarks locally:

dotnet run --project benchmarks/Hugo.Benchmarks/Hugo.Benchmarks.csproj -c Release

Generated reports are available in BenchmarkDotNet.Artifacts/results/. Hugo primitives demonstrate competitive performance with native .NET types while providing additional safety guarantees and observability hooks.

Support & policies

  • Questions & bugs: GitHub issues
  • Security disclosures: contact the maintainer privately before filing a public issue.
  • Roadmap: keep up with priorities in docs/meta/roadmap.md.

Contributing

Contributions are welcome! See CONTRIBUTING.md for detailed guidelines on:

  • Setting up your development environment
  • Code style and conventions
  • Running tests and collecting coverage
  • Submitting pull requests
  • Documentation updates

Quick start:

  1. Install the .NET 10 preview SDK alongside .NET 9.
  2. Run dotnet build Hugo.slnx and dotnet test tests/Hugo.Tests/Hugo.Tests.csproj before submitting changes.
  3. Collect coverage locally with dotnet test tests/Hugo.Tests/Hugo.Tests.csproj --collect:"XPlat Code Coverage" to mirror CI.
  4. Review docs/index.md to update tutorials, how-to guides, and references when behaviour changes.
  5. Track strategic work in docs/meta/roadmap.md and ensure new APIs include XML docs plus cancellation coverage tests.

License

Hugo is licensed under the MIT License. You are free to use, modify, and distribute this library in accordance with the license terms.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 is compatible.  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 (7)

Showing the top 5 NuGet packages that depend on Hugo:

Package Downloads
Hugo.Diagnostics.OpenTelemetry

OpenTelemetry extensions and defaults for Hugo diagnostics instrumentation.

Hugo.TaskQueues.Replication

Replication helpers, deterministic coordinators, and checkpointing sinks for Hugo task queues.

Hugo.Deterministic.Redis

Redis-backed deterministic state store for Hugo workflows.

Hugo.Deterministic.Cosmos

Azure Cosmos DB deterministic state store for Hugo workflows.

Hugo.TaskQueues.Diagnostics

TaskQueue diagnostics helpers (meters, activity sources, sampling, adapters) for Hugo hosts.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 488 11/21/2025
2.0.0-rc.7 313 11/21/2025
2.0.0-rc.6 417 11/18/2025
2.0.0-rc.5 364 11/18/2025
2.0.0-rc.3 353 11/18/2025
1.4.11 258 11/14/2025
1.4.10 347 11/13/2025
1.4.9 365 11/12/2025
1.4.8 340 11/10/2025
1.4.7 276 11/10/2025
1.4.5 265 11/10/2025
1.4.4 222 11/9/2025
1.4.3 213 11/9/2025
1.4.2 261 10/30/2025
1.4.1 192 10/30/2025
1.4.0 194 10/27/2025
1.3.6 199 10/27/2025
1.3.5 178 10/26/2025
1.3.4 180 10/26/2025
1.3.3 149 10/25/2025
1.3.2 148 10/25/2025
1.3.0 117 10/25/2025
1.1.0 160 10/24/2025
1.0.2 232 10/23/2025
1.0.1 185 10/23/2025
1.0.0 248 10/21/2025
0.5.8 186 10/21/2025
0.5.7 185 10/21/2025
0.5.6 181 10/21/2025
0.5.5 177 10/21/2025
0.5.4 173 10/21/2025
0.5.3 180 10/21/2025
0.5.2 182 10/21/2025
0.5.0 179 10/20/2025
0.4.0 181 10/20/2025
0.3.1 181 10/20/2025
0.3.0 178 10/19/2025
0.2.0 185 10/19/2025
0.1.2 183 10/19/2025
0.1.0 190 10/19/2025