HoneyDrunk.Kernel
0.2.1
See the version list below for details.
dotnet add package HoneyDrunk.Kernel --version 0.2.1
NuGet\Install-Package HoneyDrunk.Kernel -Version 0.2.1
<PackageReference Include="HoneyDrunk.Kernel" Version="0.2.1" />
<PackageVersion Include="HoneyDrunk.Kernel" Version="0.2.1" />
<PackageReference Include="HoneyDrunk.Kernel" />
paket add HoneyDrunk.Kernel --version 0.2.1
#r "nuget: HoneyDrunk.Kernel, 0.2.1"
#:package HoneyDrunk.Kernel@0.2.1
#addin nuget:?package=HoneyDrunk.Kernel&version=0.2.1
#tool nuget:?package=HoneyDrunk.Kernel&version=0.2.1
HoneyDrunk.Kernel
Runtime Implementations for the HoneyDrunk Grid - Production-ready implementations of all Kernel abstractions.
๐ What Is This?
HoneyDrunk.Kernel provides the runtime implementations of all contracts defined in HoneyDrunk.Kernel.Abstractions. This is the package you use when building executable Nodes, services, or applications that participate in the Grid.
๐ฆ What's Inside
๐ Context Implementations
- GridContext - Default implementation with causation chain support
- NodeContext - Process-scoped Node identity
- OperationContext - Operation tracking with timing and outcome
- GridContextAccessor - Async-local context accessor
๐ Context Mappers
Automatic context propagation from various sources:
- HttpContextMapper - Maps HTTP headers to GridContext
- JobContextMapper - Maps background job metadata
- MessagingContextMapper - Maps message properties for event-driven architectures
โ๏ธ Lifecycle Management
- NodeLifecycleManager - Coordinates startup/shutdown
- NodeLifecycleHost - Hosts Node lifecycle with health/readiness
๐ Diagnostics
- NoOpMetricsCollector - Zero-overhead placeholder (replace with OpenTelemetry in production)
- NodeLifecycleHealthContributor - Lifecycle-based health
- NodeContextReadinessContributor - Context-based readiness
๐ง Configuration
- StudioConfiguration - Studio-wide configuration implementation
๐ Secrets
- CompositeSecretsSource - Chains multiple secret sources with fallback logic
โค๏ธ Health
- CompositeHealthCheck - Aggregates multiple health checks
๐ Dependency Injection
- HoneyDrunkCoreExtensions - Core service registration (
AddHoneyDrunkCore,AddHoneyDrunkCoreNode) - ServiceProviderValidation - Startup validation
๐ฅ Installation
dotnet add package HoneyDrunk.Kernel
<PackageReference Include="HoneyDrunk.Kernel" Version="0.2.1" />
Note: This package automatically includes HoneyDrunk.Kernel.Abstractions as a dependency.
๐ Quick Start
Basic Node Setup
using HoneyDrunk.Kernel.Abstractions.Hosting;
using HoneyDrunk.Kernel.DependencyInjection;
var builder = WebApplication.CreateBuilder(args);
// Register Kernel services with Node descriptor
var nodeDescriptor = new NodeDescriptor
{
NodeId = "payment-node",
Version = "1.0.0",
Name = "Payment Processing Node",
Sector = "commerce",
Cluster = "payments-cluster"
};
builder.Services.AddHoneyDrunkCoreNode(nodeDescriptor);
var app = builder.Build();
// Validate services before starting
app.Services.ValidateHoneyDrunkServices();
app.Run();
Using Context in Services
public class OrderService(
IGridContext gridContext,
INodeContext nodeContext,
ILogger<OrderService> logger)
{
public async Task ProcessOrderAsync(Order order)
{
logger.LogInformation(
"Processing order {OrderId} on Node {NodeId} with correlation {CorrelationId}",
order.Id,
nodeContext.NodeId,
gridContext.CorrelationId);
// Create child context for downstream call
var childContext = gridContext.CreateChildContext("payment-node");
await _paymentService.ChargeAsync(order, childContext);
}
}
HTTP Context Mapping
// Automatically maps X-Correlation-ID, X-Causation-ID, X-Baggage-* headers
app.UseMiddleware<GridContextMiddleware>();
app.MapPost("/orders", async (Order order, IGridContext gridContext) =>
{
// gridContext is automatically populated from HTTP headers
await _orderService.ProcessOrderAsync(order);
return Results.Created($"/orders/{order.Id}", order);
});
Lifecycle Hooks
// Register startup hooks
builder.Services.AddSingleton<IStartupHook, DatabaseMigrationHook>();
builder.Services.AddSingleton<IStartupHook, CacheWarmupHook>();
// Register shutdown hooks
builder.Services.AddSingleton<IShutdownHook, ConnectionDrainHook>();
// Register health contributors
builder.Services.AddSingleton<IHealthContributor, DatabaseHealthContributor>();
builder.Services.AddSingleton<IReadinessContributor, CacheReadinessContributor>();
๐ฏ When to Use This Package
Use HoneyDrunk.Kernel when:
- โ Building an executable Node/service
- โ You need context mappers (HTTP, messaging, jobs)
- โ You need lifecycle orchestration
- โ You want production-ready implementations
Use HoneyDrunk.Kernel.Abstractions only when:
- โ Building a library (use abstractions to avoid implementation dependencies)
- โ Creating custom implementations
๐๏ธ Architecture
Context Flow
HTTP Request with X-Correlation-ID header
โ
HttpContextMapper extracts header โ GridContext
โ
GridContext injected into OrderService
โ
OrderService creates child context for PaymentService
โ
ChildContext propagates to downstream Node
Lifecycle Flow
Application Start
โ
NodeLifecycleStage = Initializing
โ
Execute IStartupHook instances (by priority)
โ
Check IReadinessContributor instances
โ
NodeLifecycleStage = Running
โ
(Application runs...)
โ
Shutdown signal received
โ
NodeLifecycleStage = Stopping
โ
Stop accepting new requests
โ
Execute IShutdownHook instances (by priority)
โ
NodeLifecycleStage = Stopped
โ๏ธ Configuration
appsettings.json
{
"Grid": {
"NodeId": "payment-node",
"Version": "1.0.0",
"StudioId": "honeycomb",
"Environment": "production",
"Tags": {
"deployment-slot": "blue",
"region": "us-east-1"
}
},
"NodeRuntime": {
"Environment": "production",
"Region": "us-east-1",
"EnableDetailedTelemetry": true,
"EnableDistributedTracing": true,
"TelemetrySamplingRate": 1.0,
"HealthCheckIntervalSeconds": 30,
"ShutdownGracePeriodSeconds": 30
}
}
๐ Related Packages
- HoneyDrunk.Kernel.Abstractions - Contracts only
- HoneyDrunk.Standards - Analyzers and coding conventions
๐ Documentation
- Complete File Guide - Comprehensive architecture documentation
- Context Guide - Context propagation patterns
- Lifecycle Guide - Lifecycle orchestration
- Implementations Guide - Runtime implementation details
๐งช Testing
See Testing Guide for patterns on:
- Mocking GridContext, NodeContext, OperationContext
- Testing with deterministic time
- Integration testing with DI
- Testing lifecycle hooks and health contributors
๐ License
This project is licensed under the MIT License.
Built with ๐ฏ by HoneyDrunk Studios
GitHub โข Documentation โข Issues
| 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
- HoneyDrunk.Kernel.Abstractions (>= 0.2.1)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Ulid (>= 1.4.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on HoneyDrunk.Kernel:
| Package | Downloads |
|---|---|
|
HoneyDrunk.Vault
Secrets and configuration management library for .NET. Provides a unified abstraction for accessing secrets from multiple providers (File, Azure Key Vault, AWS Secrets Manager, Configuration, In-Memory). Integrated with HoneyDrunk.Kernel v0.8.0 for lifecycle management, health reporting, and distributed telemetry. |
|
|
HoneyDrunk.Data
Provider-neutral persistence orchestration layer for HoneyDrunk.OS Grid. Complete architecture overhaul with Kernel integration for tenant resolution, correlation tracking, and telemetry enrichment. Does not depend on any specific database provider. |
GitHub repositories
This package is not used by any popular GitHub repositories.
v0.2.1: Fixed README emoji encoding issues. v0.2.0: Major refactor as semantic OS layer. Added GridContext implementations, context mappers for HTTP/Messaging/Jobs, lifecycle orchestration, and telemetry integration. See CHANGELOG.md for details.