Valir.Core
0.1.2
Prefix Reserved
dotnet add package Valir.Core --version 0.1.2
NuGet\Install-Package Valir.Core -Version 0.1.2
<PackageReference Include="Valir.Core" Version="0.1.2" />
<PackageVersion Include="Valir.Core" Version="0.1.2" />
<PackageReference Include="Valir.Core" />
paket add Valir.Core --version 0.1.2
#r "nuget: Valir.Core, 0.1.2"
#:package Valir.Core@0.1.2
#addin nuget:?package=Valir.Core&version=0.1.2
#tool nuget:?package=Valir.Core&version=0.1.2
Valir
A modular .NET distributed framework for background jobs and event-driven architectures.
Features
- At-Least-Once Delivery with idempotency keys
- Priority Queues - higher priority jobs processed first
- Batch Operations - enqueue thousands of jobs efficiently
- Graceful Shutdown - drain mode for zero job loss
- Transactional Outbox - atomic job creation with your DB
- Distributed Locks - Redis-backed coordination
- Rate Limiting - sliding window algorithm
- OpenTelemetry - native tracing support
Quick Start
dotnet add package Valir.Redis
dotnet add package Valir.AspNet
Configure Services
builder.Services.AddValir(options =>
{
options.RedisConnectionString = "localhost:6379";
});
Enqueue a Job
app.MapPost("/jobs", async (IJobQueue queue) =>
{
byte[] payload = JsonSerializer.SerializeToUtf8Bytes(new { Email = "user@example.com" });
string jobId = await queue.EnqueueAsync("send-email", payload);
return Results.Ok(new { JobId = jobId });
});
Run the Worker
// Define your job handler
public class EmailJobHandler : IJobHandler<EmailData>
{
public async Task HandleAsync(EmailData job, JobContext context)
{
await SendEmailAsync(job, context.CancellationToken);
}
}
// Register and run
builder.Services.AddValir(options =>
{
options.RedisConnectionString = "localhost:6379";
});
builder.Services.AddSingleton<IJobHandler<EmailData>, EmailJobHandler>();
var worker = app.Services.GetRequiredService<WorkerRuntime>();
await worker.RunAsync();
Packages
| Package | Description |
|---|---|
| Valir.Abstractions | Core interfaces (IJobQueue, IEventBroker) |
| Valir.Core | Worker runtime, retry policies |
| Valir.Redis | Redis job queue implementation |
| Valir.AspNet | ASP.NET Core integration |
| Valir.EntityFrameworkCore | Transactional Outbox pattern |
| Valir.Brokers.Kafka | Apache Kafka adapter |
| Valir.Brokers.RabbitMQ | RabbitMQ adapter |
| Valir.Brokers.AzureSB | Azure Service Bus adapter |
Configuration
builder.Services.AddValir(options =>
{
options.RedisConnectionString = "localhost:6379";
options.KeyPrefix = "valir:";
options.Concurrency = 4;
options.DefaultMaxAttempts = 3;
options.RetryBaseDelay = TimeSpan.FromSeconds(10);
options.DefaultVisibilityTimeout = TimeSpan.FromSeconds(30);
});
Event Bus
Kafka
builder.Services.AddValirKafka(options =>
{
options.BootstrapServers = "localhost:9092";
options.GroupId = "my-service";
});
RabbitMQ
builder.Services.AddValirRabbitMQ(options =>
{
options.HostName = "localhost";
options.UserName = "guest";
options.Password = "guest";
});
Azure Service Bus
builder.Services.AddValirAzureServiceBus(options =>
{
options.ConnectionString = "Endpoint=sb://...";
});
Transactional Outbox
builder.Services.AddValirOutbox<AppDbContext>();
// Jobs are written to outbox table (same transaction)
await _outboxQueue.EnqueueAsync("process-order", payload);
await _context.SaveChangesAsync(); // Atomic!
Documentation
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.2)
- System.ComponentModel.Annotations (>= 5.0.0)
- Valir.Abstractions (>= 0.1.2)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Valir.Core:
| Package | Downloads |
|---|---|
|
Valir.AspNet
ASP.NET Core integration for Valir. Provides DI extensions (AddValir), OpenTelemetry native tracing, and middleware for job queue operations. |
|
|
Valir.Redis
Redis implementation for Valir job queue. Provides RedisJobQueue, RedisDistributedLock, and RedisRateLimiter with atomic Lua scripts for reliable distributed operations. |
|
|
Valir.EntityFrameworkCore
Transactional Outbox pattern for Valir using Entity Framework Core. Ensures atomic job creation with database transactions for reliable message delivery. |
GitHub repositories
This package is not used by any popular GitHub repositories.