在好例子网,分享、交流、成长!
您当前所在位置:首页Others 开发实例一般编程问题 → FoundatioFx:构建分布式应用的可插拔基础模块

FoundatioFx:构建分布式应用的可插拔基础模块

一般编程问题

下载此实例
  • 开发语言:Others
  • 实例大小:0.53M
  • 下载次数:0
  • 浏览次数:24
  • 发布时间:2024-04-02
  • 实例类别:一般编程问题
  • 发 布 人:chenxiaolan
  • 文件格式:.zip
  • 所需积分:2
 相关标签:

实例介绍

【实例简介】
FoundatioFx是一个为构建松耦合分布式应用设计的基础模块集合,包括缓存、队列、锁、消息传递、作业和文件存储等关键组件。它支持多种实现,如Redis、Azure、AWS、RabbitMQ、Kafka以及内存(适用于开发环境)。

选择Foundatio的原因在于,在开发多个大型云应用时,我们发现缺乏一些优秀的解决方案来构建可扩展的分布式应用,同时保持开发体验的简单性。例如,我们希望能够针对抽象接口进行构建,以便轻松更换实现;我们需要这些模块对依赖注入友好;在缓存方面,我们最初使用的是一个开源的Redis缓存客户端,但后来它转为商业产品,许可成本较高,并且没有内存实现,因此每个开发者都需要设置并配置Redis。

如果你想要无痛的开发和测试体验,同时允许你的应用可扩展,那么使用Foundatio将是一个明智的选择!

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

IQueue<SimpleWorkItem> queue = new InMemoryQueue<SimpleWorkItem>();
await queue.EnqueueAsync(new SimpleWorkItem {
    Data = "Hello"
});

ILockProvider locker = new CacheLockProvider(new InMemoryCacheClient(), new InMemoryMessageBus());
var testLock = await locker.AcquireAsync("test");
// ...
await testLock.ReleaseAsync();

IMessageBus messageBus = new InMemoryMessageBus();
await messageBus.SubscribeAsync<SimpleMessageA>(msg => {
  // Got message
});
await messageBus.PublishAsync(new SimpleMessageA { Data = "Hello" });

FoundatioFx不仅提供了一整套解决方案来支持你的应用从开发到生产的全生命周期,还通过灵活的模块化设计,确保了在不同的环境和需求下都能提供最佳的性能和扩展性。
【实例截图】
【核心代码】
文件清单
└── Foundatio-89ce086393497ee2c7fb1d47f565674b52a7211c
    ├── build
    │   ├── common.props
    │   ├── foundatio-icon.png
    │   ├── Foundatio.snk
    │   └── Update-Nito.ps1
    ├── Foundatio.All.code-workspace
    ├── Foundatio.All.sln
    ├── Foundatio.sln
    ├── global.json
    ├── LICENSE.txt
    ├── media
    │   ├── colors.png
    │   ├── foundatio-dark-bg.svg
    │   ├── foundatio-icon.png
    │   ├── foundatio-icon.svg
    │   ├── foundatio.png
    │   ├── foundatio.svg
    │   └── foundatio-white.png
    ├── NuGet.config
    ├── README.md
    ├── samples
    │   ├── Directory.Build.props
    │   └── Foundatio.HostingSample
    │       ├── Foundatio.HostingSample.csproj
    │       ├── Jobs
    │       │   ├── EvenMinutesJob.cs
    │       │   ├── EveryMinuteJob.cs
    │       │   ├── Sample1Job.cs
    │       │   └── Sample2Job.cs
    │       ├── MyCriticalHealthCheck.cs
    │       ├── Program.cs
    │       ├── Properties
    │       │   └── launchSettings.json
    │       └── Startup
    │           ├── MyStartupAction.cs
    │           └── OtherStartupAction.cs
    ├── src
    │   ├── Directory.Build.props
    │   ├── Foundatio
    │   │   ├── Caching
    │   │   │   ├── CacheValue.cs
    │   │   │   ├── HybridCacheClient.cs
    │   │   │   ├── ICacheClient.cs
    │   │   │   ├── InMemoryCacheClient.cs
    │   │   │   ├── InMemoryCacheClientOptions.cs
    │   │   │   ├── NullCacheClient.cs
    │   │   │   └── ScopedCacheClient.cs
    │   │   ├── DeepCloner
    │   │   │   ├── DeepClonerExtensions.cs
    │   │   │   ├── Helpers
    │   │   │   │   ├── ClonerToExprGenerator.cs
    │   │   │   │   ├── DeepClonerCache.cs
    │   │   │   │   ├── DeepClonerExprGenerator.cs
    │   │   │   │   ├── DeepClonerGenerator.cs
    │   │   │   │   ├── DeepClonerSafeTypes.cs
    │   │   │   │   ├── DeepCloneState.cs
    │   │   │   │   ├── ReflectionHelper.cs
    │   │   │   │   ├── ShallowClonerGenerator.cs
    │   │   │   │   └── ShallowObjectCloner.cs
    │   │   │   └── LICENSE
    │   │   ├── Extensions
    │   │   │   ├── CacheClientExtensions.cs
    │   │   │   ├── CollectionExtensions.cs
    │   │   │   ├── ConcurrentDictionaryExtensions.cs
    │   │   │   ├── ConcurrentQueueExtensions.cs
    │   │   │   ├── DateTimeExtensions.cs
    │   │   │   ├── EnumerableExtensions.cs
    │   │   │   ├── EnumExtensions.cs
    │   │   │   ├── ExceptionExtensions.cs
    │   │   │   ├── LoggerExtensions.cs
    │   │   │   ├── NumberExtensions.cs
    │   │   │   ├── ObjectExtensions.cs
    │   │   │   ├── StringExtensions.cs
    │   │   │   ├── TaskExtensions.cs
    │   │   │   ├── TimespanExtensions.cs
    │   │   │   └── TypeExtensions.cs
    │   │   ├── Foundatio.csproj
    │   │   ├── Jobs
    │   │   │   ├── IJob.cs
    │   │   │   ├── IQueueJob.cs
    │   │   │   ├── JobAttribute.cs
    │   │   │   ├── JobBase.cs
    │   │   │   ├── JobContext.cs
    │   │   │   ├── JobOptions.cs
    │   │   │   ├── JobResult.cs
    │   │   │   ├── JobRunner.cs
    │   │   │   ├── JobWithLockBase.cs
    │   │   │   ├── QueueEntryContext.cs
    │   │   │   ├── QueueJobBase.cs
    │   │   │   └── WorkItemJob
    │   │   │       ├── WorkItemContext.cs
    │   │   │       ├── WorkItemData.cs
    │   │   │       ├── WorkItemHandlers.cs
    │   │   │       ├── WorkItemJob.cs
    │   │   │       ├── WorkItemQueueExtensions.cs
    │   │   │       └── WorkItemStatus.cs
    │   │   ├── Lock
    │   │   │   ├── CacheLockProvider.cs
    │   │   │   ├── DisposableLockCollection.cs
    │   │   │   ├── DisposableLock.cs
    │   │   │   ├── ILockProvider.cs
    │   │   │   ├── ScopedLockProvider.cs
    │   │   │   └── ThrottlingLockProvider.cs
    │   │   ├── Messaging
    │   │   │   ├── IMessageBus.cs
    │   │   │   ├── IMessagePublisher.cs
    │   │   │   ├── IMessageSubscriber.cs
    │   │   │   ├── InMemoryMessageBus.cs
    │   │   │   ├── InMemoryMessageBusOptions.cs
    │   │   │   ├── MessageBusBase.cs
    │   │   │   ├── Message.cs
    │   │   │   ├── NullMessageBus.cs
    │   │   │   └── SharedMessageBusOptions.cs
    │   │   ├── Metrics
    │   │   │   ├── BufferedMetricsClientBase.cs
    │   │   │   ├── CacheBucketMetricsClientBase.cs
    │   │   │   ├── CounterStat.cs
    │   │   │   ├── DiagnosticsMetricsClient.cs
    │   │   │   ├── DiagnosticsMetricsClientOptions.cs
    │   │   │   ├── GaugeStat.cs
    │   │   │   ├── IHaveSubMetricName.cs
    │   │   │   ├── IMetricsClient.cs
    │   │   │   ├── IMetricsClientStats.cs
    │   │   │   ├── InMemoryMetricsClient.cs
    │   │   │   ├── InMemoryMetricsClientOptions.cs
    │   │   │   ├── MetricKey.cs
    │   │   │   ├── MetricTimer.cs
    │   │   │   ├── NullMetricsClient.cs
    │   │   │   ├── SharedMetricsClientOptions.cs
    │   │   │   ├── StatsDMetricsClient.cs
    │   │   │   ├── StatsDMetricsClientOptions.cs
    │   │   │   └── TimingStat.cs
    │   │   ├── Nito.AsyncEx.Coordination
    │   │   │   ├── AsyncAutoResetEvent.cs
    │   │   │   ├── AsyncConditionVariable.cs
    │   │   │   ├── AsyncCountdownEvent.cs
    │   │   │   ├── AsyncLazy.cs
    │   │   │   ├── AsyncLock.cs
    │   │   │   ├── AsyncManualResetEvent.cs
    │   │   │   ├── AsyncReaderWriterLock.cs
    │   │   │   ├── AsyncSemaphore.cs
    │   │   │   ├── AsyncWaitQueue.cs
    │   │   │   ├── IdManager.cs
    │   │   │   └── LICENSE
    │   │   ├── Nito.AsyncEx.Tasks
    │   │   │   ├── AwaitableDisposable.cs
    │   │   │   ├── CancellationTokenTaskSource.cs
    │   │   │   ├── ExceptionHelpers.cs
    │   │   │   ├── LICENSE
    │   │   │   ├── Synchronous
    │   │   │   │   └── TaskExtensions.cs
    │   │   │   ├── TaskCompletionSourceExtensions.cs
    │   │   │   ├── TaskConstants.cs
    │   │   │   └── TaskExtensions.cs
    │   │   ├── Nito.Collections.Deque
    │   │   │   ├── CollectionHelpers.cs
    │   │   │   ├── Deque.cs
    │   │   │   └── LICENSE
    │   │   ├── Nito.Disposables
    │   │   │   ├── AnonymousDisposable.cs
    │   │   │   ├── Internals
    │   │   │   │   └── BoundAction.cs
    │   │   │   ├── LICENSE
    │   │   │   └── SingleDisposable.cs
    │   │   ├── Properties
    │   │   │   └── AssemblyInfo.cs
    │   │   ├── Queues
    │   │   │   ├── DuplicateDetectionQueueBehavior.cs
    │   │   │   ├── InMemoryQueue.cs
    │   │   │   ├── InMemoryQueueOptions.cs
    │   │   │   ├── IQueueActivity.cs
    │   │   │   ├── IQueue.cs
    │   │   │   ├── IQueueEntry.cs
    │   │   │   ├── MetricsQueueBehavior.cs
    │   │   │   ├── QueueBase.cs
    │   │   │   ├── QueueBehaviour.cs
    │   │   │   ├── QueueEntry.cs
    │   │   │   ├── QueueStatSummary.cs
    │   │   │   └── SharedQueueOptions.cs
    │   │   ├── Serializer
    │   │   │   ├── IHaveSerializer.cs
    │   │   │   ├── ISerializer.cs
    │   │   │   └── SystemTextJsonSerializer.cs
    │   │   ├── Storage
    │   │   │   ├── ActionableStream.cs
    │   │   │   ├── FolderFileStorage.cs
    │   │   │   ├── FolderFileStorageOptions.cs
    │   │   │   ├── IFileStorage.cs
    │   │   │   ├── InMemoryFileStorage.cs
    │   │   │   ├── InMemoryFileStorageOptions.cs
    │   │   │   ├── ScopedFileStorage.cs
    │   │   │   └── StreamMode.cs
    │   │   └── Utility
    │   │       ├── AsyncEvent.cs
    │   │       ├── ConnectionStringParser.cs
    │   │       ├── DataDictionary.cs
    │   │       ├── DisposableAction.cs
    │   │       ├── EmptyDisposable.cs
    │   │       ├── FoundatioDiagnostics.cs
    │   │       ├── IAsyncDisposable.cs
    │   │       ├── IAsyncLifetime.cs
    │   │       ├── IHaveLogger.cs
    │   │       ├── InstrumentsValues.cs
    │   │       ├── MaintenanceBase.cs
    │   │       ├── OptionsBuilder.cs
    │   │       ├── PathHelper.cs
    │   │       ├── Run.cs
    │   │       ├── ScheduledTimer.cs
    │   │       ├── SharedOptions.cs
    │   │       ├── SystemClock.cs
    │   │       ├── TimeUnit.cs
    │   │       └── TypeHelper.cs
    │   ├── Foundatio.AppMetrics
    │   │   ├── AppMetricsClient.cs
    │   │   └── Foundatio.AppMetrics.csproj
    │   ├── Foundatio.DataProtection
    │   │   ├── Extensions
    │   │   │   └── DataProtectionBuilderExtensions.cs
    │   │   ├── Foundatio.DataProtection.csproj
    │   │   └── FoundatioStorageXmlRepository.cs
    │   ├── Foundatio.Extensions.Hosting
    │   │   ├── Cronos
    │   │   │   ├── CalendarHelper.cs
    │   │   │   ├── CronExpression.cs
    │   │   │   ├── CronExpressionFlag.cs
    │   │   │   ├── CronField.cs
    │   │   │   ├── CronFormat.cs
    │   │   │   ├── CronFormatException.cs
    │   │   │   └── TimeZoneHelper.cs
    │   │   ├── Foundatio.Extensions.Hosting.csproj
    │   │   ├── Jobs
    │   │   │   ├── HostedJobOptions.cs
    │   │   │   ├── HostedJobService.cs
    │   │   │   ├── JobHostExtensions.cs
    │   │   │   ├── JobOptionsBuilder.cs
    │   │   │   ├── ScheduledJobRegistration.cs
    │   │   │   ├── ScheduledJobService.cs
    │   │   │   └── ShutdownHostIfNoJobsRunningService.cs
    │   │   └── Startup
    │   │       ├── IStartupAction.cs
    │   │       ├── RunStartupActionsService.cs
    │   │       ├── StartupActionRegistration.cs
    │   │       ├── StartupActionsContext.cs
    │   │       ├── StartupExtensions.cs
    │   │       ├── StartupHealthcheck.cs
    │   │       ├── StartupPriorityAttribute.cs
    │   │       └── WaitForStartupActionsBeforeServingRequestsMiddleware.cs
    │   ├── Foundatio.JsonNet
    │   │   ├── Foundatio.JsonNet.csproj
    │   │   └── JsonNetSerializer.cs
    │   ├── Foundatio.MessagePack
    │   │   ├── Foundatio.MessagePack.csproj
    │   │   └── MessagePackSerializer.cs
    │   ├── Foundatio.MetricsNET
    │   │   ├── Foundatio.MetricsNET.csproj
    │   │   └── MetricsNETClient.cs
    │   ├── Foundatio.TestHarness
    │   │   ├── Caching
    │   │   │   ├── CacheClientTestsBase.cs
    │   │   │   └── HybridCacheClientTests.cs
    │   │   ├── Extensions
    │   │   │   └── TaskExtensions.cs
    │   │   ├── Foundatio.TestHarness.csproj
    │   │   ├── GlobalSuppressions.cs
    │   │   ├── Jobs
    │   │   │   ├── HelloWorldJob.cs
    │   │   │   ├── JobQueueTestsBase.cs
    │   │   │   ├── SampleQueueJob.cs
    │   │   │   ├── ThrottledJob.cs
    │   │   │   ├── WithDependencyJob.cs
    │   │   │   └── WithLockingJob.cs
    │   │   ├── Locks
    │   │   │   └── LockTestBase.cs
    │   │   ├── Messaging
    │   │   │   ├── MessageBusTestBase.cs
    │   │   │   └── Samples.cs
    │   │   ├── Metrics
    │   │   │   ├── DiagnosticsMetricsCollector.cs
    │   │   │   └── MetricsClientTestBase.cs
    │   │   ├── Queue
    │   │   │   ├── QueueTestBase.cs
    │   │   │   └── Samples.cs
    │   │   ├── Serializer
    │   │   │   └── SerializerTestsBase.cs
    │   │   ├── Storage
    │   │   │   └── FileStorageTestsBase.cs
    │   │   └── Utility
    │   │       ├── BenchmarkToJson.cs
    │   │       ├── Configuration.cs
    │   │       └── NonSeekableStream.cs
    │   ├── Foundatio.Utf8Json
    │   │   ├── Foundatio.Utf8Json.csproj
    │   │   └── Utf8JsonSerializer.cs
    │   └── Foundatio.Xunit
    │       ├── Foundatio.Xunit.csproj
    │       ├── Logging
    │       │   ├── LogEntry.cs
    │       │   ├── TestLogger.cs
    │       │   ├── TestLoggerFactory.cs
    │       │   └── TestWithLoggingBase.cs
    │       └── Retry
    │           ├── DelayedMessageBus.cs
    │           ├── RetryAttribute.cs
    │           ├── RetryFactDiscoverer.cs
    │           ├── RetryTestCase.cs
    │           ├── RetryTheoryAttribute.cs
    │           ├── RetryTheoryDiscoverer.cs
    │           └── RetryTheoryTestCase.cs
    └── tests
        ├── Directory.Build.props
        └── Foundatio.Tests
            ├── Caching
            │   ├── InMemoryCacheClientTests.cs
            │   └── InMemoryHybridCacheClientTests.cs
            ├── Foundatio.Tests.csproj
            ├── Hosting
            │   ├── HostingTests.cs
            │   └── TestServerExtensions.cs
            ├── Jobs
            │   ├── InMemoryJobQueueTests.cs
            │   ├── JobTests.cs
            │   └── WorkItemJobTests.cs
            ├── Locks
            │   └── InMemoryLockTests.cs
            ├── Messaging
            │   └── InMemoryMessageBusTests.cs
            ├── Metrics
            │   ├── DiagnosticsMetricsTests.cs
            │   └── InMemoryMetricsTests.cs
            ├── Properties
            │   └── AssemblyInfo.cs
            ├── Queue
            │   └── InMemoryQueueTests.cs
            ├── Serializer
            │   ├── CompressedMessagePackSerializerTests.cs
            │   ├── JsonNetSerializerTests.cs
            │   ├── MessagePackSerializerTests.cs
            │   ├── SystemTextJsonSerializerTests.cs
            │   └── Utf8JsonSerializerTests.cs
            ├── Storage
            │   ├── FolderFileStorageTests.cs
            │   ├── InMemoryFileStorageTests.cs
            │   ├── ScopedFolderFileStorageTests.cs
            │   └── ScopedInMemoryFileStorageTests.cs
            └── Utility
                ├── CloneTests.cs
                ├── ConnectionStringParserTests.cs
                ├── DataDictionaryTests.cs
                ├── RunTests.cs
                ├── ScheduledTimerTests.cs
                ├── SystemClockTests.cs
                └── TestUdpListener.cs

68 directories, 285 files

标签:

实例下载地址

FoundatioFx:构建分布式应用的可插拔基础模块

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警