ServiceStack:如何使用分布式RedisEvents?

ServiceStack: how to use distributed RedisEvents?

关于分布式 RedisEvents 如何在 ServiceStack 中工作的文档(我发现的)很少。

文档说:

One limitation the default MemoryServerEvents implementation has is being limited for use within a single App Server where all client connections are maintained. This is no longer a limitation with the new Redis ServerEvents back-end which utilizes a distributed redis-server back-end to provide a scale-out option capable of serving fan-out/load-balanced App Servers. If you’re familiar with SignalR, this is akin to SignalR’s scaleout with Redis back-end.

它还说明了如何添加插件,但是没有其他关于事件如何分发、如何 post 分发事件以及如何处理哪个节点对其做出反应以及 post 到将到达正确终端客户的渠道。

我是不是遗漏了什么或者几乎没有相关文档?

RedisServerEvents 的文档位于:http://docs.servicestack.net/redis-server-events

在 API 中使用在 IServerEvents API 后面透明工作的 In Memory 或 Redis Server Events 后端没有区别。唯一的区别在于注册,您需要使用配置的 IRedisClientsManager:

注册 RedisServerEvents
var redisHost = AppSettings.GetString("RedisHost");
if (redisHost != null)
{
    container.Register<IRedisClientsManager>(
        new RedisManagerPool(redisHost));

    container.Register<IServerEvents>(c => 
        new RedisServerEvents(c.Resolve<IRedisClientsManager>()));

    container.Resolve<IServerEvents>().Start();
}

这将默认内存 IServerEvents 替换为 RedisServerEvents 实现,该实现发送 API 调用 Redis Pub/Sub 以通知所有配置了相同 [=11] 的应用程序服务器=] 将服务器事件发送到本地 /event-stream.

上连接的客户端的配置