Ejemplo n.º 1
0
 public RedisGroupRepository(MessagePackSerializerOptions serializerOptions, RedisGroupOptions redisGroupOptions, IMagicOnionLogger logger)
 {
     this.serializerOptions = serializerOptions;
     this.logger            = logger;
     this.factory           = CreateGroup;
     this.connection        = redisGroupOptions.ConnectionMultiplexer;
     this.db = redisGroupOptions.Db;
 }
Ejemplo n.º 2
0
        public IGroupRepository CreateRepository(MessagePackSerializerOptions serializerOptions, IMagicOnionLogger logger, IServiceLocator serviceLocator)
        {
            var options = serviceLocator.GetService <RedisGroupOptions>();

            if (options == null)
            {
                var connection = serviceLocator.GetService <ConnectionMultiplexer>();
                if (connection == null)
                {
                    throw new InvalidOperationException("RedisGroup requires add ConnectionMultiplexer to MagicOnionOptions.ServiceLocator before create it. Please try new MagicOnionOptions{DefaultServiceLocator.Register(new ConnectionMultiplexer)}");
                }

                options = new RedisGroupOptions(connection);
            }

            return(new RedisGroupRepository(serializerOptions, options, logger));
        }