コード例 #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));
 }