forked from yevhen/Streamstone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
S02_Open_stream_for_writing.cs
39 lines (33 loc) · 1.02 KB
/
S02_Open_stream_for_writing.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Threading.Tasks;
using Streamstone;
namespace Example.Scenarios
{
public class S02_Open_stream_for_writing : Scenario
{
public override async Task RunAsync()
{
await OpenNonExistingStream();
await OpenExistingStream();
}
async Task OpenNonExistingStream()
{
try
{
await Stream.OpenAsync(Partition);
}
catch (StreamNotFoundException)
{
Console.WriteLine("Opening non-existing stream will throw StreamNotFoundException");
}
}
async Task OpenExistingStream()
{
await Stream.ProvisionAsync(Partition);
var stream = await Stream.OpenAsync(Partition);
Console.WriteLine("Opened existing (empty) stream in partition '{0}'", stream.Partition);
Console.WriteLine("Etag: {0}", stream.ETag);
Console.WriteLine("Version: {0}", stream.Version);
}
}
}