Skip to content

msbolton/Conduit

Repository files navigation

Conduit Framework for .NET

Version .NET License

A comprehensive messaging and component framework for building scalable, maintainable microservices and distributed systems in C#/.NET.

Overview

Conduit is a plugin-based messaging framework that provides:

  • Component-Based Architecture: Dynamic discovery and lifecycle management of pluggable components
  • CQRS Pattern: First-class support for Commands, Queries, and Events
  • Pipeline Processing: Flexible behavior chain for message processing
  • Multi-Transport Support: AMQP/RabbitMQ, gRPC, TCP, and Kafka adapters
  • Enterprise Features: Saga orchestration, security, resilience patterns, and metrics
  • Hot Reload: Dynamic component loading and unloading without restart

Project Structure

Conduit/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ Conduit.Api/                 # Core interfaces and contracts
β”‚   β”œβ”€β”€ Conduit.Core/                # Framework implementation
β”‚   β”œβ”€β”€ Conduit.Common/              # Shared utilities
β”‚   β”œβ”€β”€ Conduit.Pipeline/            # Pipeline framework
β”‚   β”œβ”€β”€ Conduit.Components/          # Component system
β”‚   β”œβ”€β”€ Conduit.Messaging/           # Message bus and routing
β”‚   β”œβ”€β”€ Conduit.Saga/                # Distributed transaction orchestration
β”‚   β”œβ”€β”€ Conduit.Security/            # Authentication and authorization
β”‚   β”œβ”€β”€ Conduit.Resilience/          # Circuit breakers and retry policies
β”‚   β”œβ”€β”€ Conduit.Persistence/         # Database adapters
β”‚   β”œβ”€β”€ Conduit.Serialization/       # Multi-format serialization
β”‚   β”œβ”€β”€ Conduit.Transports/          # Transport implementations
β”‚   β”‚   β”œβ”€β”€ Conduit.Transports.Core/
β”‚   β”‚   β”œβ”€β”€ Conduit.Transports.Amqp/
β”‚   β”‚   β”œβ”€β”€ Conduit.Transports.Grpc/
β”‚   β”‚   └── Conduit.Transports.Tcp/
β”‚   └── Conduit.Application/         # Application host
β”œβ”€β”€ tests/                           # Unit and integration tests
β”œβ”€β”€ examples/                        # Example implementations
└── docker/                          # Docker configuration

Quick Start

Prerequisites

  • .NET 8 SDK
  • Docker (optional, for running infrastructure)

Building the Framework

# Clone the repository
git clone https://github.com/conduit/conduit-dotnet.git
cd Conduit

# Build the solution
dotnet build

# Run tests
dotnet test

# Run with Docker
docker-compose up -d

Creating a Component

using Conduit.Api;

[Component("my-component", "My Component", "1.0.0")]
public class MyComponent : IPluggableComponent
{
    public string Id => "my-component";
    public string Name => "My Component";
    public string Version => "1.0.0";
    public string Description => "A sample component";

    public async Task OnAttachAsync(ComponentContext context, CancellationToken cancellationToken)
    {
        // Initialize component
        context.Logger.LogInformation("Component attached");
    }

    public IEnumerable<IBehaviorContribution> ContributeBehaviors()
    {
        // Return behaviors to add to the pipeline
        yield break;
    }

    public IEnumerable<MessageHandlerRegistration> RegisterHandlers()
    {
        // Register command, event, and query handlers
        yield return MessageHandlerRegistration.ForCommand<CreateOrderCommand, CreateOrderCommandHandler>();
    }
}

Sending Commands

public class CreateOrderCommand : ICommand<OrderCreatedResult>
{
    public string CustomerId { get; set; }
    public List<OrderItem> Items { get; set; }
}

// Send command
var result = await messageBus.SendAsync(new CreateOrderCommand
{
    CustomerId = "123",
    Items = new List<OrderItem> { ... }
});

Publishing Events

public class OrderCreatedEvent : IEvent
{
    public string OrderId { get; set; }
    public string CustomerId { get; set; }
    public decimal TotalAmount { get; set; }
}

// Publish event
await messageBus.PublishAsync(new OrderCreatedEvent
{
    OrderId = "456",
    CustomerId = "123",
    TotalAmount = 99.99m
});

Executing Queries

public class GetOrderQuery : IQuery<Order>
{
    public string OrderId { get; set; }
}

// Execute query
var order = await messageBus.QueryAsync(new GetOrderQuery { OrderId = "456" });

Core Concepts

Components

Components are the building blocks of the Conduit framework. They can:

  • Contribute behaviors to the message pipeline
  • Register message handlers
  • Provide services to other components
  • Expose features for discovery

Pipeline

The message pipeline processes all messages through a chain of behaviors. Components contribute behaviors that can:

  • Validate messages
  • Add security context
  • Log and collect metrics
  • Transform messages
  • Handle errors

Message Bus

The central message bus handles:

  • Command routing (one handler)
  • Event publishing (multiple handlers)
  • Query execution (one handler)
  • Pipeline execution

Features

πŸ”Œ Plugin Architecture

  • Dynamic component discovery
  • Hot reload support
  • Dependency management
  • Isolation levels

πŸ“¬ Messaging

  • CQRS pattern implementation
  • Request-response for commands/queries
  • Pub-sub for events
  • Message correlation and causation tracking

πŸ”„ Pipeline Processing

  • Behavior chain pattern
  • Ordered behavior placement
  • Interceptors and middleware
  • Conditional behavior execution

πŸ”’ Security

  • Authentication and authorization
  • Security context propagation
  • Audit logging
  • Encryption support

πŸ’ͺ Resilience

  • Circuit breaker pattern
  • Retry policies with backoff
  • Timeout management
  • Bulkhead isolation

πŸ“Š Observability

  • Metrics collection (Prometheus compatible)
  • Distributed tracing support
  • Structured logging
  • Health checks

πŸ—„οΈ Persistence

  • Multiple database support (PostgreSQL, MongoDB, Redis)
  • Caching abstraction
  • Transaction management
  • Repository pattern

πŸš€ Transports

  • AMQP/RabbitMQ
  • gRPC
  • TCP/Sockets
  • Kafka (planned)

Configuration

Configuration is handled through appsettings.json:

{
  "Conduit": {
    "Components": {
      "DiscoveryPath": "./components",
      "EnableHotReload": true
    },
    "Messaging": {
      "DefaultTimeout": 30000,
      "MaxRetries": 3
    },
    "Transports": {
      "Amqp": {
        "ConnectionString": "amqp://localhost:5672"
      }
    }
  }
}

Documentation

Examples

See the /examples directory for complete examples:

  • OrderService: CQRS implementation with event sourcing
  • NotificationService: Event-driven notifications
  • GatewayService: API gateway with routing

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

License

This project is licensed under the Business Source License 1.1 - see the LICENSE file for details.

Support

Acknowledgments

This is a C# port of the original Java Conduit framework, maintaining architectural compatibility while leveraging .NET ecosystem features.

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors