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