public ResultProjectionInfo(
     RedisResultInfo result,
     ResultProjectionKind kind,
     int?index = null)
     : this(result, kind, default(byte[]), index)
 {
 }
 public ResultProjectionInfo(
     RedisResultInfo result,
     ResultProjectionKind kind,
     long value,
     int?index = null)
     : this(result, kind, value.ToString(), index)
 {
 }
 public ResultProjectionInfo(
     RedisResultInfo result,
     ResultProjectionKind kind,
     string value,
     int?index = null)
     : this(result, kind, Encoding.UTF8.GetBytes(value), index)
 {
 }
 public ResultProjectionInfo(
     RedisResultInfo result,
     ResultProjectionKind kind,
     byte[] value,
     int?index = null)
 {
     Result = result;
     Kind   = kind;
     Value  = value;
     Index  = index;
 }
Example #5
0
 public IObservable <RedisResultInfo> Execute(
     RedisTargetInfo targetInfo, RedisCommandInfo commandInfo)
 {
     return(_clientAccessor.With(targetInfo, client =>
     {
         // TODO: async
         return client.Call(commandInfo.Name, commandInfo.Args);
     })
            .Select(data => RedisResultInfo.MapResult(
                        targetInfo,
                        commandInfo,
                        data))
            .Catch <RedisResultInfo, RedisException>(exception => Observable.Return(
                                                         new RedisResultInfo.Error(
                                                             targetInfo,
                                                             commandInfo,
                                                             exception))));
 }
Example #6
0
        public IObservable <RedisResultInfo> Execute(
            RedisTargetInfo targetInfo, RedisBatchInfo batchInfo)
        {
            return(_clientAccessor.With(targetInfo, client =>
            {
                return Observable.Create <RedisResultInfo>(observer =>
                {
                    foreach (var commandInfo in batchInfo.CommandInfos)
                    {
                        try
                        {
                            // TODO: async
                            var data = client.Call(commandInfo.Name, commandInfo.Args);

                            if (commandInfo.IsExec && batchInfo.IsTransaction)
                            {
                                observer.OnNext(
                                    RedisResultInfo.MapResult(
                                        targetInfo, batchInfo, commandInfo, data));
                            }
                            else
                            {
                                observer.OnNext(
                                    RedisResultInfo.MapResult(
                                        targetInfo, commandInfo, data));
                            }
                        }
                        catch (RedisException e)
                        {
                            observer.OnNext(new RedisResultInfo.Error(
                                                targetInfo, commandInfo, e));
                        }
                    }

                    observer.OnCompleted();
                    return Disposable.Empty;
                });
            }));
        }