{"id":30693397,"url":"https://github.com/mikasjp/BusyBee","last_synced_at":"2025-09-02T06:02:22.116Z","repository":{"id":310266543,"uuid":"1036008276","full_name":"mikasjp/BusyBee","owner":"mikasjp","description":"Lightweight library for in-memory background processing in .NET applications.","archived":false,"fork":false,"pushed_at":"2025-08-26T11:00:19.000Z","size":1466,"stargazers_count":103,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-02T05:02:21.740Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikasjp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-11T12:26:34.000Z","updated_at":"2025-08-31T19:05:37.000Z","dependencies_parsed_at":"2025-08-16T23:26:44.437Z","dependency_job_id":"b9f5bf06-02e6-460e-ad30-4d8aa37c6d95","html_url":"https://github.com/mikasjp/BusyBee","commit_stats":null,"previous_names":["mikasjp/ignis","mikasjp/busybee"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mikasjp/BusyBee","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikasjp%2FBusyBee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikasjp%2FBusyBee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikasjp%2FBusyBee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikasjp%2FBusyBee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikasjp","download_url":"https://codeload.github.com/mikasjp/BusyBee/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikasjp%2FBusyBee/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273233235,"owners_count":25068731,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-02T06:01:12.937Z","updated_at":"2025-09-02T06:02:22.079Z","avatar_url":"https://github.com/mikasjp.png","language":"C#","funding_links":[],"categories":["Background Processing"],"sub_categories":[],"readme":"# BusyBee\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003e🐝💨 Fast and observable background job processing for .NET\u003c/strong\u003e\n\u003c/p\u003e\n\n---\n\n[![NuGet Version](https://img.shields.io/nuget/v/BusyBee)](https://www.nuget.org/packages/BusyBee#versions-body-tab)\n![License](https://img.shields.io/github/license/mikasjp/BusyBee)\n[![Build and Test](https://github.com/mikasjp/BusyBee/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/mikasjp/BusyBee/actions/workflows/tests.yml)\n\n---\n\nBusyBee is a high-performance .NET background processing library built on native channels. It provides a simple, configurable, and observable solution for handling background tasks with built-in OpenTelemetry support and flexible queue management.\n\n## Installation\n\n```bash\ndotnet add package BusyBee\n```\n\n## Quick Start\n\nRegister BusyBee in your DI container and start processing background jobs:\n\n```csharp\n// Program.cs\nbuilder.Services.AddBusyBee();\n\n// Inject IBackgroundQueue and enqueue jobs\nawait queue.Enqueue(async (services, context, cancellationToken) =\u003e\n{\n    var logger = services.GetRequiredService\u003cILogger\u003cProgram\u003e\u003e();\n    logger.LogInformation(\"Processing job {JobId}\", context.JobId);\n    \n    await Task.Delay(1000, cancellationToken);\n}, cancellationToken);\n```\n\n## Features\n\n### 🚀 **High Performance**\n- In-memory queues built on .NET channels for efficiency\n\n### ⚙️ **Highly Configurable**\n- Unbounded or bounded queues with multiple overflow strategies\n- Configurable job timeouts both globally and per job\n- Parallel job processing with configurable slots pool size\n\n### 📊 **Built-in Observability**\n- Job execution flow logging\n- Tracing ready for OpenTelemetry\n- Detailed OpenTelemetry ready metrics (jobs count, execution times, wait times, and more...)\n\n### 🔧 **Developer Friendly**\n- Fluent configuration API\n- Full dependency injection support\n- Comprehensive cancellation token support\n- Rich job context information\n\n## Configuration\n\n### Basic Configuration\n\n```csharp\nbuilder.Services\n    .AddBusyBee()\n    .WithUnboundedQueue()\n    .WithGlobalJobTimeout(TimeSpan.FromSeconds(30))\n    .WithLevelOfParallelism(10);\n```\n\n### Queue Configuration\n\n**Unbounded Queue** - No capacity limits:\n```csharp\nbuilder.Services.AddBusyBee().WithUnboundedQueue();\n```\n\n**Bounded Queue** - With capacity and overflow handling:\n```csharp\n// Throw exception when queue is full\nbuilder.Services.AddBusyBee()\n    .WithBoundedQueue(capacity: 1000, OverflowStrategy.ThrowException);\n\n// Drop oldest jobs when queue is full\nbuilder.Services.AddBusyBee()\n    .WithBoundedQueue(capacity: 1000, OverflowStrategy.DropOldest);\n```\n\nSupported overflow strategies:\n\n* Wait - Wait until space is available,\n* Ignore - Ignore the job if queue is full,\n* ThrowException - Throw an exception if queue is full,\n* DiscardOldest - Discard the oldest job in the queue,\n* DiscardNewest - Discard the newest job in the queue\n\n### Timeout Management\n\n```csharp\n// Set global timeout for all jobs\nbuilder.Services.AddBusyBee()\n    .WithGlobalJobTimeout(TimeSpan.FromSeconds(30));\n```\n\n### Performance Tuning\n\n```csharp\n// Process multiple jobs in parallel\nbuilder.Services.AddBusyBee()\n    .WithLevelOfParallelism(20);\n```\n\n## Job Context\n\nEvery job receives a rich context with useful information:\n\n```csharp\nawait queue.Enqueue(async (services, context, cancellationToken) =\u003e\n{\n    // Unique job identifier\n    var jobId = context.JobId;\n    \n    // Timing information\n    var queuedAt = context.QueuedAt;\n    var startedAt = context.StartedAt;\n    var waitTime = startedAt - queuedAt;\n    \n    // Access any registered service\n    var myService = services.GetRequiredService\u003cIMyService\u003e();\n});\n```\n\n## OpenTelemetry Integration\nBusyBee supports OpenTelemetry for metrics and tracing. This allows you to monitor and analyze job performance in production environments.\nEnable OpenTelemetry in your application:\n\n```csharp\nbuilder.Services.AddOpenTelemetry()\n    .WithTracing(tracing =\u003e tracing\n        .AddSource(BusyBee.Observability.TracingConstants.TraceSourceName)\n        .AddConsoleExporter())\n    .WithMetrics(metrics =\u003e metrics\n        .AddMeter(BusyBee.Observability.MetricsConstants.MeterName)\n        .AddPrometheusExporter());\n```\n\n## Example app\n\nSee the [DemoApp](examples/DemoApp/README.md) for a complete example of BusyBee in action, including:\n- Web API with Swagger UI for API exploration \n- OpenTelemetry tracing and metrics setup\n- Seq for centralized logging and tracing\n- Prometheus integration for metrics scraping\n- Docker Compose setup for easy deployment\n\n## Advanced Usage\n\n### Errors and timeouts handling\n\nImplement and register your own `IJobFailureHandler` to handle job failures.\n\n```csharp\nservices.AddBusyBee()\n    .WithJobFailureHandler\u003cMyCustomJobFailureHandler\u003e();\n```\n\nTo handle job timeouts, you can implement and register `IJobTimeoutHandler`:\n\n```csharp\nservices.AddBusyBee()\n    .WithJobTimeoutHandler\u003cMyCustomJobTimeoutHandler\u003e();\n```\n\n### Long-Running Jobs\n\n```csharp\nawait queue.Enqueue(async (services, context, cancellationToken) =\u003e\n{\n    var logger = services.GetRequiredService\u003cILogger\u003e();\n    \n    for (int i = 0; i \u003c 1000; i++)\n    {\n        // Check for cancellation periodically\n        cancellationToken.ThrowIfCancellationRequested();\n        \n        await ProcessItemAsync(i, cancellationToken);\n        \n        // Log progress\n        if (i % 100 == 0)\n        {\n            logger.LogInformation(\"Job {JobId}: Processed {Count}/1000 items\", \n                context.JobId, i);\n        }\n    }\n}, cancellationToken);\n```\n\n## Best Practices\n\n1. **Keep jobs idempotent** - Design jobs to be safely retryable\n2. **Use appropriate timeouts** - Set realistic timeouts based on your job complexity\n3. **Monitor jobs** - Use OpenTelemetry to track jobs\n4. **Handle cancellation** - Always respect `CancellationToken` in long-running jobs\n\n## Contributing\n\nWe welcome contributions! Please feel free to:\n\n- 🐛 Report bugs\n- 💡 Suggest new features\n- 🔧 Submit pull requests\n- 📖 Improve documentation","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikasjp%2FBusyBee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikasjp%2FBusyBee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikasjp%2FBusyBee/lists"}