Thanks to visit codestin.com
Credit goes to foundatio.dev

Skip to content

FoundatioBuilding Blocks for Distributed Apps

Pluggable foundation blocks for building loosely coupled distributed applications

Foundatio

Quick Examples

Caching

csharp
using Foundatio.Caching;

ICacheClient cache = new InMemoryCacheClient();
await cache.SetAsync("test", 1);
var value = await cache.GetAsync<int>("test");

Learn more about Caching →

Queues

csharp
using Foundatio.Queues;

IQueue<SimpleWorkItem> queue = new InMemoryQueue<SimpleWorkItem>();

await queue.EnqueueAsync(new SimpleWorkItem { Data = "Hello" });
var workItem = await queue.DequeueAsync();

Learn more about Queues →

Locks

csharp
using Foundatio.Lock;

ILockProvider locker = new CacheLockProvider(
    new InMemoryCacheClient(),
    new InMemoryMessageBus()
);

await using var lck = await locker.AcquireAsync("resource");
if (lck is null)
    throw new InvalidOperationException("Could not acquire lock");

// Do exclusive work
await ProcessAsync();

Learn more about Locks →

Messaging

csharp
using Foundatio.Messaging;

IMessageBus messageBus = new InMemoryMessageBus();
await messageBus.SubscribeAsync<SimpleMessage>(msg => {
  // Got message
});

await messageBus.PublishAsync(new SimpleMessage { Data = "Hello" });

Learn more about Messaging →

File Storage

csharp
using Foundatio.Storage;

IFileStorage storage = new InMemoryFileStorage();
await storage.SaveFileAsync("test.txt", "test");
string content = await storage.GetFileContentsAsync("test.txt");

Learn more about File Storage →

Resilience

csharp
using Foundatio.Resilience;

var policy = new ResiliencePolicyBuilder()
    .WithMaxAttempts(3)
    .WithExponentialDelay(TimeSpan.FromSeconds(1))
    .Build();

await policy.ExecuteAsync(async ct => {
    await SomeUnreliableOperationAsync(ct);
});

Learn more about Resilience →

Why Foundatio?

When building several large cloud applications we found a lack of great solutions for many key pieces to building scalable distributed applications while keeping the development experience simple. Here's why we built and use Foundatio:

  • Abstract Interfaces: Build against abstract interfaces so you can easily change implementations
  • DI Friendly: All blocks are dependency injection friendly
  • Local Development: In-memory implementations mean no external dependencies during development
  • Swappable: Easily swap between in-memory (development) and production implementations (Redis, Azure, AWS)
  • Battle Tested: Used in production at Exceptionless and other large-scale applications
  • Open Source: Released under the permissive Apache 2.0 License
  • Actively Maintained: Continuously developed and improved since 2015 (10+ years of production use)

Implementations

ProviderCachingQueuesMessagingLocksStorage
Aliyun
AWS
Azure ServiceBus
Azure Storage
In-Memory
Kafka
Minio
RabbitMQ
Redis
SshNet
  • Foundatio.CommandQuery - CQRS framework with Entity Framework Core and MongoDB support, built on Foundatio.Mediator.
  • Foundatio.Lucene - Lucene-style query parser with AST, visitor pattern, Entity Framework Core integration, and Elasticsearch Query DSL generation.
  • Foundatio.Mediator - Blazingly fast, convention-based C# mediator powered by source generators and interceptors. Near-direct call performance with zero runtime reflection.
  • Foundatio.Parsers - Extensible Lucene-style query syntax parser with Elasticsearch integration.
  • Foundatio.Repositories - Generic repository pattern implementation with Elasticsearch support, caching, and message bus integration.

Released under the Apache 2.0 License.