@@ -16,42 +16,42 @@ public static async Task EnsureJoinProjection(this EventStoreProjectionManagemen
16
16
await client . CreateContinuousAsync ( outputStream , query , true ) ;
17
17
}
18
18
19
- private static async Task Update ( EventStoreProjectionManagementClient client , string outputStream , string query )
19
+ private static async Task Update ( EventStoreProjectionManagementClient client , string outputStream , string query , CancellationToken token = default )
20
20
{
21
- var state = await client . GetStatusAsync ( outputStream ) ;
21
+ var state = await client . GetStatusAsync ( outputStream , cancellationToken : token ) ;
22
22
if ( state ! . Status != "Stopped" )
23
- await client . DisableAsync ( outputStream ) ;
24
- await client . UpdateAsync ( outputStream , query , true ) ;
25
- await client . EnableAsync ( outputStream ) ;
23
+ await client . DisableAsync ( outputStream , cancellationToken : token ) ;
24
+ await client . UpdateAsync ( outputStream , query , true , cancellationToken : token ) ;
25
+ await client . EnableAsync ( outputStream , cancellationToken : token ) ;
26
26
}
27
27
28
- public static async Task EnsureLookupProjection ( this EventStoreProjectionManagementClient client , IProjectionRegister register , string category , string eventProperty , string outputStreamCategory )
28
+ public static async Task EnsureLookupProjection ( this EventStoreProjectionManagementClient client , IProjectionRegister register , string category , string eventProperty , string outputStreamCategory , CancellationToken token = default )
29
29
{
30
30
string query =
31
31
$ "fromStreams(['$ce-{ category } ']).when( {{ \n $any : function(s,e) {{ \n if(e.body && e.body.{ eventProperty } ) {{\n linkTo('{ outputStreamCategory } -' + e.body.{ eventProperty } , e) \n }}\n \n }}\n }});";
32
32
if ( ( await register . Get ( outputStreamCategory ) ) != null )
33
33
await Update ( client , outputStreamCategory , query ) ;
34
34
else
35
35
{
36
- await client . CreateContinuousAsync ( outputStreamCategory , query , false ) ;
37
- await client . DisableAsync ( outputStreamCategory ) ;
38
- await client . UpdateAsync ( outputStreamCategory , query , true ) ;
39
- await client . EnableAsync ( outputStreamCategory ) ;
36
+ await client . CreateContinuousAsync ( outputStreamCategory , query , false , cancellationToken : token ) ;
37
+ await client . DisableAsync ( outputStreamCategory , cancellationToken : token ) ;
38
+ await client . UpdateAsync ( outputStreamCategory , query , true , cancellationToken : token ) ;
39
+ await client . EnableAsync ( outputStreamCategory , cancellationToken : token ) ;
40
40
}
41
41
}
42
42
public static async Task EnsureJoinProjection ( this EventStoreProjectionManagementClient client ,
43
- string outputStream , IProjectionRegister register , IEnumerable < string > eventTypes )
43
+ string outputStream , IProjectionRegister register , IEnumerable < string > eventTypes , CancellationToken token = default )
44
44
{
45
45
var query = CreateQuery ( outputStream , eventTypes ) ;
46
46
47
47
if ( ( await register . Get ( outputStream ) ) != null )
48
- await Update ( client , outputStream , query ) ;
48
+ await Update ( client , outputStream , query , token ) ;
49
49
else
50
50
{
51
- await client . CreateContinuousAsync ( outputStream , query , false ) ;
52
- await client . DisableAsync ( outputStream ) ;
53
- await client . UpdateAsync ( outputStream , query , true ) ;
54
- await client . EnableAsync ( outputStream ) ;
51
+ await client . CreateContinuousAsync ( outputStream , query , false , cancellationToken : token ) ;
52
+ await client . DisableAsync ( outputStream , cancellationToken : token ) ;
53
+ await client . UpdateAsync ( outputStream , query , true , cancellationToken : token ) ;
54
+ await client . EnableAsync ( outputStream , cancellationToken : token ) ;
55
55
}
56
56
}
57
57
0 commit comments