public RiakResult <IEnumerable <RiakResult <TResult> > > PbcRepeatRead <TResult>(Func <RiakResult <TResult>, bool> repeatRead) where TResult : class, new() { var results = new List <RiakResult <TResult> >(); try { RiakResult <TResult> result; do { result = RiakResult <TResult> .Success(socket.Read <TResult>()); results.Add(result); }while (repeatRead(result)); return(RiakResult <IEnumerable <RiakResult <TResult> > > .Success(results)); } catch (RiakException ex) { if (ex.NodeOffline) { Disconnect(); } return(RiakResult <IEnumerable <RiakResult <TResult> > > .FromException(ResultCode.CommunicationError, ex, ex.NodeOffline)); } catch (Exception ex) { Disconnect(); return(RiakResult <IEnumerable <RiakResult <TResult> > > .FromException(ResultCode.CommunicationError, ex, true)); } }
public RiakResult <TResult> PbcRead <TResult>() where TResult : class, new() { try { var result = socket.Read <TResult>(); return(RiakResult <TResult> .Success(result)); } catch (RiakException ex) { if (ex.NodeOffline) { Disconnect(); } if (ex.Message.Contains("Bucket cannot be zero-length") || ex.Message.Contains("Key cannot be zero-length")) { return(RiakResult <TResult> .FromException(ResultCode.InvalidRequest, ex, ex.NodeOffline)); } return(RiakResult <TResult> .FromException(ResultCode.CommunicationError, ex, ex.NodeOffline)); } catch (Exception ex) { Disconnect(); return(RiakResult <TResult> .FromException(ResultCode.CommunicationError, ex, true)); } }
private RiakResult DoExecute(Func <RiakResult> socketFunc) { try { return(socketFunc()); } catch (RiakException ex) { if (ex.NodeOffline) { Disconnect(); } return(RiakResult.FromException(ResultCode.CommunicationError, ex, ex.NodeOffline)); } catch (Exception ex) { Disconnect(); return(RiakResult.FromException(ResultCode.CommunicationError, ex, true)); } }
public RiakResult PbcRead(MessageCode expectedMessageCode) { try { socket.Read(expectedMessageCode); return(RiakResult.Success()); } catch (RiakException ex) { if (ex.NodeOffline) { Disconnect(); } return(RiakResult.FromException(ResultCode.CommunicationError, ex, ex.NodeOffline)); } catch (Exception ex) { Disconnect(); return(RiakResult.FromException(ResultCode.CommunicationError, ex, true)); } }
public RiakResult PbcWrite <TRequest>(TRequest request) where TRequest : class { try { socket.Write(request); return(RiakResult.Success()); } catch (RiakException ex) { if (ex.NodeOffline) { Disconnect(); } return(RiakResult.FromException(ResultCode.CommunicationError, ex, ex.NodeOffline)); } catch (Exception ex) { Disconnect(); return(RiakResult.FromException(ResultCode.CommunicationError, ex, true)); } }