public VanillaDataStorageReceiver(VanillaDataStorage dataStorage, string name, IEndianAwareReader reader, ISerializer serializer, RequestResponseMapper mapper) { Validate.Require(dataStorage != null, "You must supply a valid dataStorage"); Validate.Require(name.Length > 0, "You must supply a valid name"); Validate.Require(reader != null, "A reader object is required"); Validate.Require(serializer != null, "A serializer object is required"); Validate.Require(mapper != null, "A mapper object is required"); this.dataStorage = dataStorage; this.Name = name; this.reader = reader; this.serializer = serializer; this.mapper = mapper; }
public IResponseState Parse(Header header, IEndianAwareReader reader) { var success = reader.ReadIntAsBool(); var journalSize = new Offset(reader.ReadInt32()); return new CommitResponseState(success, journalSize); }
public IResponseState Parse(Header header, IEndianAwareReader reader) { throw new InvalidOperationException("Header " + header.ToString() + " is not mapped to a valid response parser."); }
public IResponseState Parse(Header header, IEndianAwareReader reader) { var success = reader.ReadBool(); return new RollbackResponseState(success); }
public IResponseState Parse(Header header, IEndianAwareReader reader) { // How many bytes will we read from the stream? var numBytes = reader.ReadInt32(); // Fill the byte array with bytes left from the previous read. // This is neccessary when reading chunks of data var writer = new IntrusiveByteArrayWriter(); writer.Insert(previousState.BytesLeft); // Read the bytes into the intrusive byte array reader.ReadBytes(numBytes, writer); if (writer.Length > 0) { if (header.IsMultipart) return ReadJournal(new InputStreamBytes(writer), false); else return ReadJournal(new InputStreamBytes(writer), true); } else return new ReadJournalResponseState(0, new List<Event>(), true, new byte[0]); }
public IResponseState Parse(Header header, IEndianAwareReader reader) { var journalSize = new Offset(reader.ReadInt32()); var transactionUID = new TransactionUID(reader.ReadInt32()); return new NewTransactionResponseState(journalSize, transactionUID); }
public IResponseState Parse(Header header, IEndianAwareReader reader) { var exists = reader.ReadBool(); return new JournalExistsResponseState(exists); }
public IResponseState Parse(Header header, IEndianAwareReader reader) { var errorId = reader.ReadInt32(); throw new EverstoreException(ErrorToString(errorId)); }