예제 #1
0
파일: DB.cs 프로젝트: streamsdb/driver
        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,
            });
        }
예제 #2
0
파일: DB.cs 프로젝트: streamsdb/driver
        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);
        }
예제 #3
0
파일: DB.cs 프로젝트: streamsdb/driver
 public bool Equals(GlobalPosition other)
 {
     return(Value.Equals(other.Value));
 }