コード例 #1
0
        public IEnumerable <T> Batch <T>(Func <IRiakBatchClient, IEnumerable <T> > batchFunction)
        {
            var batchEndPoint = new RiakBatch(_endPoint);
            var batchedClient = new RiakClient(batchEndPoint);

            return(batchFunction(batchedClient));
        }
コード例 #2
0
        public T Batch <T>(Func <IRiakBatchClient, T> batchFunction)
        {
            var batchEndPoint = new RiakBatch(_endPoint);
            var batchedClient = new RiakClient(batchEndPoint);

            return(batchFunction(batchedClient));
        }
コード例 #3
0
        public void Batch(Action <IRiakBatchClient> batchAction)
        {
            var batchEndPoint = new RiakBatch(_endPoint);
            var batchedClient = new RiakClient(batchEndPoint);

            batchAction(batchedClient);
        }
コード例 #4
0
 public T Batch <T>(Func <IRiakBatchClient, T> batchFun)
 {
     return(WaitFor(_client.Batch(ac => {
         var c = new RiakClient((RiakAsyncClient)ac);
         var s = new TaskCompletionSource <T>();
         s.SetResult(batchFun(c));
         return s.Task;
     })));
 }
コード例 #5
0
 public Task Batch(Action <IRiakBatchClient> batchAction)
 {
     return(Batch <object>(ac => {
         return Task <object> .Factory.StartNew(() => {
             var c = new RiakClient((RiakAsyncClient)ac);
             batchAction(c);
             return new object();
         });
     }));
 }
コード例 #6
0
        public async Task <Either <RiakException, RiakObject> > Get(string bucket, string key, RiakGetOptions options = null)
        {
            options = options ?? RiakClient.DefaultGetOptions();

            if (!IsValidBucketOrKey(bucket))
            {
                return(new Either <RiakException, RiakObject>(new RiakException((uint)ResultCode.InvalidRequest, InvalidBucketErrorMessage, false)));
            }

            if (!IsValidBucketOrKey(key))
            {
                return(new Either <RiakException, RiakObject>(new RiakException((uint)ResultCode.InvalidRequest, InvalidKeyErrorMessage, false)));
            }

            var request = new RpbGetReq {
                bucket = bucket.ToRiakString(), key = key.ToRiakString()
            };

            options = options ?? new RiakGetOptions();
            options.Populate(request);

            try
            {
                var result = await _connection.PbcWriteRead <RpbGetReq, RpbGetResp>(_endPoint, request).ConfigureAwait(false);

                if (result.vclock == null)
                {
                    return(new Either <RiakException, RiakObject>(new RiakException((uint)ResultCode.NotFound, "Unable to find value in Riak", false)));
                }

                var riakObject = new RiakObject(bucket, key, result.content, result.vclock);

                return(new Either <RiakException, RiakObject>(riakObject));
            }
            catch (RiakException riakException)
            {
                return(new Either <RiakException, RiakObject>(riakException));
            }
        }
コード例 #7
0
 public void Get(IEnumerable <RiakObjectId> bucketKeyPairs, Action <IEnumerable <RiakResult <RiakObject> > > callback, RiakGetOptions options = null)
 {
     options = options ?? RiakClient.DefaultGetOptions();
     ExecAsync(() => callback(_client.Get(bucketKeyPairs, options)));
 }
コード例 #8
0
 public void Get(RiakObjectId objectId, Action <RiakResult <RiakObject> > callback, RiakGetOptions options = null)
 {
     options = options ?? RiakClient.DefaultGetOptions();
     ExecAsync(() => callback(_client.Get(objectId.Bucket, objectId.Key, options)));
 }
コード例 #9
0
 public void Get(string bucket, string key, Action <RiakResult <RiakObject> > callback, RiakGetOptions options = null)
 {
     options = options ?? RiakClient.DefaultGetOptions();
     ExecAsync(() => callback(_client.Get(bucket, key, options)));
 }
コード例 #10
0
 public Task <IEnumerable <RiakResult <RiakObject> > > Get(IEnumerable <RiakObjectId> bucketKeyPairs, RiakGetOptions options = null)
 {
     options = options ?? RiakClient.DefaultGetOptions();
     return(Task.Factory.StartNew(() => _client.Get(bucketKeyPairs, options)));
 }
コード例 #11
0
 public Task <RiakResult <RiakObject> > Get(RiakObjectId objectId, RiakGetOptions options = null)
 {
     options = options ?? RiakClient.DefaultGetOptions();
     return(Task.Factory.StartNew(() => _client.Get(objectId.Bucket, objectId.Key, options)));
 }
コード例 #12
0
 public Task <RiakResult <RiakObject> > Get(string bucket, string key, RiakGetOptions options = null)
 {
     options = options ?? RiakClient.DefaultGetOptions();
     return(Task.Factory.StartNew(() => _client.Get(bucket, key, options)));
 }