@@ -29,10 +29,6 @@ public async Task SimpleLocalExecutionExample()
2929 {
3030 var services = GetDelegateServiceFactory ( ) ;
3131 var timeoutsAndLimits = new HalibutTimeoutsAndLimitsForTestsBuilder ( ) . Build ( ) ;
32- timeoutsAndLimits = new HalibutTimeoutsAndLimits ( ) ;
33-
34- // Use a shared queue factory so client and worker share the same queue
35- var queueFactory = new PendingRequestQueueFactoryAsync ( timeoutsAndLimits , new LogFactory ( ) ) ;
3632
3733 var logFactory = new CachingLogFactory ( new TestContextLogCreator ( "" , LogLevel . Trace ) ) ;
3834
@@ -44,22 +40,21 @@ public async Task SimpleLocalExecutionExample()
4440
4541 await using var client = new HalibutRuntimeBuilder ( )
4642 . WithServerCertificate ( Certificates . Octopus )
47- . WithPendingRequestQueueFactory ( RedisFactory ( ) )
43+ . WithPendingRequestQueueFactory ( RedisFactory ( preSharedGuid , disposables , log , logFactory ) )
4844 . WithHalibutTimeoutsAndLimits ( timeoutsAndLimits )
4945 . Build ( ) ;
5046
5147 await using var worker = new HalibutRuntimeBuilder ( )
5248 . WithServerCertificate ( Certificates . TentaclePolling )
5349 . WithServiceFactory ( services )
54- . WithPendingRequestQueueFactory ( RedisFactory ( ) )
50+ . WithPendingRequestQueueFactory ( RedisFactory ( preSharedGuid , disposables , log , logFactory ) )
5551 . WithHalibutTimeoutsAndLimits ( timeoutsAndLimits )
5652 . Build ( ) ;
5753
5854 // Start worker polling for local://test-worker
5955 using var workerCts = new CancellationTokenSource ( ) ;
6056 var pollingTask = Task . Run ( async ( ) =>
6157 {
62- //await Task.Delay(TimeSpan.FromSeconds(10));
6358 await worker . PollLocalAsync ( new Uri ( "local://test-worker" ) , workerCts . Token ) ;
6459 } , workerCts . Token ) ;
6560
@@ -72,23 +67,29 @@ public async Task SimpleLocalExecutionExample()
7267
7368 await workerCts . CancelAsync ( ) ;
7469
75- Func < QueueMessageSerializer , IPendingRequestQueueFactory > RedisFactory ( )
70+ await pollingTask ;
71+ }
72+
73+ Func < QueueMessageSerializer , IPendingRequestQueueFactory > RedisFactory (
74+ Guid preSharedGuid ,
75+ DisposableCollection disposables ,
76+ TestContextLogCreator log ,
77+ CachingLogFactory logFactory )
78+ {
79+ return msgSer =>
7680 {
77- return msgSer =>
78- {
79- var redisFacade = RedisFacadeBuilder . CreateRedisFacade ( prefix : preSharedGuid ) ;
80- disposables . AddAsyncDisposable ( redisFacade ) ;
81- var watchForRedisLosingAllItsData = new WatchForRedisLosingAllItsData ( redisFacade , log . CreateNewForPrefix ( "watcher" ) ) ;
82- disposables . AddAsyncDisposable ( watchForRedisLosingAllItsData ) ;
81+ var redisFacade = RedisFacadeBuilder . CreateRedisFacade ( prefix : preSharedGuid ) ;
82+ disposables . AddAsyncDisposable ( redisFacade ) ;
83+ var watchForRedisLosingAllItsData = new WatchForRedisLosingAllItsData ( redisFacade , log . CreateNewForPrefix ( "watcher" ) ) ;
84+ disposables . AddAsyncDisposable ( watchForRedisLosingAllItsData ) ;
8385
84- return new RedisPendingRequestQueueFactory ( msgSer ,
85- new InMemoryStoreDataStreamsForDistributedQueues ( ) ,
86- watchForRedisLosingAllItsData ,
87- new HalibutRedisTransport ( redisFacade ) ,
88- new HalibutTimeoutsAndLimitsForTestsBuilder ( ) . Build ( ) ,
89- logFactory ) ;
90- } ;
91- }
86+ return new RedisPendingRequestQueueFactory ( msgSer ,
87+ new InMemoryStoreDataStreamsForDistributedQueues ( ) ,
88+ watchForRedisLosingAllItsData ,
89+ new HalibutRedisTransport ( redisFacade ) ,
90+ new HalibutTimeoutsAndLimitsForTestsBuilder ( ) . Build ( ) ,
91+ logFactory ) ;
92+ } ;
9293 }
9394
9495 static DelegateServiceFactory GetDelegateServiceFactory ( )
0 commit comments