Example #1
0
 static IEnumerable <byte[]> EnumerateStaging(string location)
 {
     using (var fs = FileEventStoreChunk.OpenForReading(location))
     {
         foreach (var msg in fs.ReadAll(0, int.MaxValue))
         {
             yield return(msg.EventData);
         }
     }
 }
Example #2
0
        static long PrepareStaging(IEnumerable <byte[]> eventData, string location)
        {
            using (var fs = FileEventStoreChunk.CreateNew(location))
            {
                var result = fs.Append("", eventData.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("At least one event is expected in batch");
                }
                return(result.WrittenBytes);
            }
        }