public static Position ParsePosition(this ReadOnlyMemory <byte> json)
        {
            var checkPoint      = json.ParseJson <string>();
            var parts           = checkPoint.Split('/');
            var commitPosition  = ulong.Parse(parts[0].Split(':')[1]);
            var preparePosition = ulong.Parse(parts[1].Split(':')[1]);

            return(new Position(commitPosition, preparePosition));
        }
예제 #2
0
        public static PersistentSubscriptionConfig FromSerializedForm(ReadOnlyMemory <byte> data)
        {
            try {
                var ret = data.ParseJson <PersistentSubscriptionConfig>();
                if (ret.Version == null)
                {
                    throw new BadConfigDataException("Deserialized but no version present, invalid configuration data.",
                                                     null);
                }

                UpdateIfRequired(ret);

                return(ret);
            } catch (Exception ex) {
                throw new BadConfigDataException("The config data appears to be invalid", ex);
            }
        }
예제 #3
0
        public EpochRecord GetEpochRecord()
        {
            if (SystemRecordType != SystemRecordType.Epoch)
            {
                throw new ArgumentException(
                          string.Format("Unexpected type of system record. Requested: {0}, actual: {1}.",
                                        SystemRecordType.Epoch, SystemRecordType));
            }

            switch (SystemRecordSerialization)
            {
            case SystemRecordSerialization.Json: {
                var dto = Data.ParseJson <EpochRecord.EpochRecordDto>();
                return(new EpochRecord(dto));
            }

            default:
                throw new ArgumentOutOfRangeException(
                          string.Format("Unexpected SystemRecordSerialization type: {0}", SystemRecordSerialization),
                          "SystemRecordSerialization");
            }
        }
        public static StreamPosition ParseStreamPosition(this ReadOnlyMemory <byte> json)
        {
            var checkPoint = json.ParseJson <string>();

            return(StreamPosition.FromInt64(int.Parse(checkPoint)));
        }