public async Task <string> Index()
        {
            var before = pool.GetConnectionInformations();
            var rng    = new Random();
            await redisDatabase.AddAsync($"key-{rng}", rng.Next());

            var after = pool.GetConnectionInformations();

            return(BuildInfo(before) + "\t" + BuildInfo(after));
        public async Task <string> Index()
        {
            var before = pool.GetConnectionInformations();
            var rng    = new Random();
            await redisDatabase.AddAsync($"key-{rng}", rng.Next());

            var after = pool.GetConnectionInformations();

            return(BuildInfo(before) + "\t" + BuildInfo(after));

            string BuildInfo(ConnectionPoolInformation info)
            {
                return($"\talive: {info.ActiveConnections.ToString()}, required: {info.RequiredPoolSize.ToString()}, ready: {info.ReadyNotUsedYet.ToString()}");
            }
        }
Example #3
0
        public async Task <IActionResult> Index()
        {
            var redisInfo = await redisDatabase.GetInfoAsync();

            var connectionInfo = connectionPoolManager.GetConnectionInformations();

            return(Ok(new { RedisInfo = redisInfo, ConnectionInfo = connectionInfo }));
        }
Example #4
0
        public async Task Invoke(HttpContext context)
        {
            logger.LogTrace("{0} --> Handling request: {1}", nameof(RedisInformationMiddleware), context.Request.Path);

            if (context.Request.Method == "GET" && context.Request.Path == "/redis/connectionInfo")
            {
                if (!IsClientAllowed(context))
                {
                    await next.Invoke(context);

                    return;
                }

                var data = connectionPoolManager.GetConnectionInformations();

                await JsonSerializer.SerializeAsync(context.Response.Body, data);

                return;
            }

            if (context.Request.Method == "GET" && context.Request.Path == "/redis/info")
            {
                if (!IsClientAllowed(context))
                {
                    await next.Invoke(context);

                    return;
                }

                var data = await redisDatabase.GetInfoAsync();

                await JsonSerializer.SerializeAsync(context.Response.Body, data);

                return;
            }

            await next.Invoke(context);
        }