Esempio n. 1
0
        public async Task <IGlobalSlice> ReadGlobalForward(GlobalPosition from, int limit)
        {
            var reply = await _client.ReadGlobalAsync(new ReadGlobalRequest
            {
                Database = _db,
                From     = from.Value,
                Limit    = limit,
            }, _metadata);

            var messages = new Message[reply.Messages.Count];

            for (int i = 0; i < reply.Messages.Count; i++)
            {
                var am = reply.Messages[i];

                messages[i] = new Message
                {
                    Stream    = am.Stream,
                    Position  = am.Position,
                    Type      = am.Type,
                    Timestamp = am.Timestamp.ToDateTime(),
                    Header    = am.Header.ToByteArray(),
                    Value     = am.Value.ToByteArray(),
                };
            }

            return(new GlobalSlice
            {
                From = new GlobalPosition(reply.From),
                Next = new GlobalPosition(reply.Next),
                Messages = messages,
            });
        }
Esempio n. 2
0
        public static bool TryParse(string value, out GlobalPosition result)
        {
            ByteString bytes;

            try{
                bytes = ByteString.FromBase64(value);
            } catch (FormatException) {
                result = null;
                return(false);
            }

            result = new GlobalPosition(bytes);
            return(true);
        }
Esempio n. 3
0
 public bool Equals(GlobalPosition other)
 {
     return(Value.Equals(other.Value));
 }