Avoid error for Redis.
This commit is contained in:
parent
ac78e6d3a0
commit
b959508410
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<LangVersion>12.0</LangVersion>
|
||||
<BotSharpVersion>3.0.0</BotSharpVersion>
|
||||
<BotSharpVersion>4.0.0</BotSharpVersion>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ It's written in C# running on .Net Core that is full cross-platform framework, t
|
|||
* Built-in multi-agents and conversation with state management.
|
||||
* Support multiple LLM Planning approaches to handle different tasks from simple to complex.
|
||||
* Built-in RAG related interfaces, Memory based vector searching.
|
||||
* Support multiple AI platforms (ChatGPT 3.5 / 4.0, PaLM 2, LLaMA 3, Claude Sonnet 3.5, HuggingFace).
|
||||
* Support multiple AI platforms (ChatGPT 3.5/ 4o/ o1, Gemini 2, LLaMA 3, Claude Sonnet 3.5, HuggingFace).
|
||||
* Allow multiple agents with different responsibilities cooperate to complete complex tasks.
|
||||
* Build, test, evaluate and audit your LLM agent in one place.
|
||||
* Build-in `BotSharp UI` written in [SvelteKit](https://kit.svelte.dev/).
|
||||
|
|
|
|||
|
|
@ -105,6 +105,11 @@ public static class BotSharpCoreExtensions
|
|||
var dbSettings = new BotSharpDatabaseSettings();
|
||||
config.Bind("Database", dbSettings);
|
||||
|
||||
if (string.IsNullOrEmpty(dbSettings.Redis))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
services.AddSingleton<IConnectionMultiplexer>(ConnectionMultiplexer.Connect(dbSettings.Redis));
|
||||
services.AddSingleton<IEventPublisher, RedisPublisher>();
|
||||
services.AddSingleton<IEventSubscriber, RedisSubscriber>();
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ namespace BotSharp.Core.Infrastructures;
|
|||
|
||||
public class DistributedLocker : IDistributedLocker
|
||||
{
|
||||
private readonly IConnectionMultiplexer _redis;
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public DistributedLocker(IConnectionMultiplexer redis, ILogger<DistributedLocker> logger)
|
||||
public DistributedLocker(IServiceProvider services, ILogger<DistributedLocker> logger)
|
||||
{
|
||||
_redis = redis;
|
||||
_services = services;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
|
@ -19,7 +19,8 @@ public class DistributedLocker : IDistributedLocker
|
|||
{
|
||||
var timeout = TimeSpan.FromSeconds(timeoutInSeconds);
|
||||
|
||||
var @lock = new RedisDistributedLock(resource, _redis.GetDatabase());
|
||||
var redis = _services.GetRequiredService<IConnectionMultiplexer>();
|
||||
var @lock = new RedisDistributedLock(resource, redis.GetDatabase());
|
||||
await using (var handle = await @lock.TryAcquireAsync(timeout))
|
||||
{
|
||||
if (handle == null)
|
||||
|
|
@ -37,7 +38,8 @@ public class DistributedLocker : IDistributedLocker
|
|||
{
|
||||
var timeout = TimeSpan.FromSeconds(timeoutInSeconds);
|
||||
|
||||
var @lock = new RedisDistributedLock(resource, _redis.GetDatabase());
|
||||
var redis = _services.GetRequiredService<IConnectionMultiplexer>();
|
||||
var @lock = new RedisDistributedLock(resource, redis.GetDatabase());
|
||||
using (var handle = @lock.TryAcquire(timeout))
|
||||
{
|
||||
if (handle == null)
|
||||
|
|
|
|||
Loading…
Reference in a new issue