static IEnumerable <byte[]> EnumerateStaging(CloudPageBlob location, long size)
 {
     using (var fs = AzureEventStoreChunk.OpenExistingForReading(location, size))
     {
         foreach (var msg in fs.ReadAll(0, size, int.MaxValue))
         {
             yield return(msg.EventData);
         }
     }
 }
Beispiel #2
0
        static long PrepareStaging(IEnumerable <byte[]> events, CloudPageBlob blob)
        {
            using (var fs = AzureEventStoreChunk.CreateNewForWriting(blob))
            {
                var result = fs.Append("", events.Select(r =>
                {
                    if (r.Length > MessageSizeLimit)
                    {
                        throw new PlatformClientException(
                            string.Format("Messages can't be larger than {0} bytes",
                                          MessageSizeLimit));
                    }

                    return(r);
                }));

                if (result.WrittenEvents == 0)
                {
                    throw new PlatformClientException("More than 0 events are expected in input collection");
                }

                return(result.ChunkPosition);
            }
        }