Beispiel #1
0
        private static async Task <RedisService> NewRedisService(bool useDic)
        {
            RedisService redisService = new RedisService(_lastRedisId++, _redisConnectionConfiguration);

            if (useDic)
            {
                _dicRedisService.Add(_lastRedisId, _pubRedisService);
            }

            await redisService.SetAsync();

            return(redisService);
        }
Beispiel #2
0
        static async Task MainAsync(string[] args)
        {
            //log4net 환경 처리
            InitLog4Net();

            IntConfig(args);

            try
            {
                _pubRedisService = await NewRedisService(true);

                _subRedisService = await NewRedisService(true);

                Console.WriteLine("Your input (q to quit)");
                Console.WriteLine("");
                Console.WriteLine("ex) psub \"pattern/*\" d1000 s2 c");
                Console.WriteLine("Subscribe a pattern/* with 2 subscriber and delay 1000ms, certenly(2way handshake).");
                Console.WriteLine("1 always corresponds to the same service, and in the case of 2 or more, it becomes a increment service from 2.");
                Console.WriteLine("");
                Console.WriteLine("ex) pub \"pattern/aaa\" \"message\" d1 w10 c");
                Console.WriteLine("Publish a pattern/aaa with 10 repeat and delay 1ms, certenly(2way handshake)");
                Console.WriteLine("");
                Console.WriteLine("ex) punsub \"pattern/*\" s2");
                Console.WriteLine("UnSubscribe a pattern/* with 2 subscriber");
                Console.WriteLine("1 always corresponds to the same service, and in the case of 2 or more, it becomes a increment service from 2.");
                Console.WriteLine("");

                string input;
                do
                {
                    input = Console.ReadLine();

                    Match match;
                    if (UsePublish(input, out match))
                    {
                        Console.WriteLine($"UsePublish : {input}");
                        await PublishAsync(match);
                    }
                    else if (UsePSubs(input, out match))
                    {
                        Console.WriteLine($"UsePSubs : {input}");
                        await PSubsAsync(match);
                    }
                    else if (UsePUnSubs(input, out match))
                    {
                        Console.WriteLine($"UsePUnSubs : {input}");
                        await PUnSubsAsync(match);
                    }
                    //else if (input.ToLower() == "d1")
                    //{
                    //    Console.WriteLine($"DELETE RedisService : {input}");
                    //    DisposeRedisService(true, _subRedisService);
                    //}
                    else
                    {
                        Console.WriteLine($"Unknown Command : {input}");
                    }
                } while (string.IsNullOrWhiteSpace(input) || input.ToLower() != "q");

                Console.WriteLine("bye bye");
            }
            catch (Exception ex)
            {
                _logger.Error("Error MainAsync", ex);
            }
        }