public void Test() { var client = Play_all_for_BlobStreaming.GetCustom(); client.RetryPolicy = RetryPolicies.NoRetry(); var root = new BlobStreamingRoot(client); var cont = root.GetContainer("tests").Create(); var storageItem = cont.GetItem("test"); storageItem.Write(w => w.WriteByte(1), options: StreamingWriteOptions.CompressIfPossible); storageItem.ReadInto((props, stream) => stream.CopyTo(new MemoryStream(), 10)); var format = storageItem.GetInfo(); string ctx; if (!format.Value.Properties.TryGetValue("ContentMD5", out ctx)) { ctx = "None"; } Console.WriteLine("MD5: {0}", ctx); //storageItem.ReadText(); }
public void Test() { var client = Play_all_for_BlobStreaming.GetCustom(); client.RetryPolicy = RetryPolicies.NoRetry(); var root = new BlobStreamingRoot(client); var cont = root.GetContainer("tests").Create(); var storageItem = cont.GetItem("test"); storageItem.Write(w => w.WriteByte(1), options : StreamingWriteOptions.CompressIfPossible); storageItem.ReadInto((props, stream) => stream.CopyTo(new MemoryStream(), 10)); var format = storageItem.GetInfo(); string ctx; if (!format.Value.Properties.TryGetValue("ContentMD5", out ctx)) { ctx = "None"; } Console.WriteLine("MD5: {0}", ctx); //storageItem.ReadText(); }
public static CqrsEngineBuilder Configure(string localStorage, string storageConnectionString) { var dev = AzureStorage.CreateConfig(storageConnectionString, c => c.ConfigureBlobClient(x => x.ReadAheadInBytes = 0x200000L)); var builder = new CqrsEngineBuilder(); JsonSerialization.SetForMessages(builder); builder.MessagesWithHandlersFromAutofac(d => { d.HandlerSample<IHandle<Define.Command>>(m => m.Handle(null)); d.InAssemblyOf<RunTaskCommand>(); }); builder.Azure(m => { m.AddAzureSender(dev, IdFor.CommandsQueue); m.AddAzureProcess(dev, IdFor.CommandsQueue, x => { x.DispatchAsCommandBatch(f => f.WhereMessagesAre<Define.Command>()); x.Quarantine(c => new Quarantine(c.Resolve<IStreamingRoot>())); x.DecayPolicy(TimeSpan.FromSeconds(0.75)); }); m.AddAzureSender(dev, IdFor.EventsQueue); m.AddAzureProcess(dev, IdFor.EventsQueue, x => { x.DispatchAsEvents(f => f.WhereMessagesAre<Define.Event>()); x.Quarantine(c => new Quarantine(c.Resolve<IStreamingRoot>())); x.DecayPolicy(TimeSpan.FromSeconds(0.75)); }); }); builder.Storage(m => { m.AtomicIsInAzure(dev, x => { x.FolderForEntity(t => "template-view-" + t.Name.ToLowerInvariant()); x.NameForEntity((t, o) => o.ToString().ToLowerInvariant() + ".json"); x.FolderForSingleton("template-singleton"); x.NameForSingleton(t => t.Name.ToLowerInvariant() + ".json"); JsonSerialization.SetForStorage(x); }); m.StreamingIsInAzure(dev); }); builder.Advanced.RegisterQueueWriterFactory(c => new AzureQueueWriterFactory(dev, c.Resolve<IEnvelopeStreamer>())); builder.Advanced.ConfigureContainer(cb => { var queueWriterRegistry = cb.Resolve<QueueWriterRegistry>(); var factory = queueWriterRegistry.GetOrThrow(dev.AccountName); var client = new BusClient(factory.GetWriteQueue(IdFor.CommandsQueue), factory.GetWriteQueue(IdFor.EventsQueue)); cb.Register<IBusClient>(client); var local = new FileStreamingContainer(localStorage); var remote = new BlobStreamingRoot(dev.CreateBlobClient()); cb.Register(new StorageProvider(local, remote)); cb.Register<IStreamingRoot>(remote); builder.Setup.AddProcess(new ScanTaskBlob(client, remote)); }); return builder; }