@@ -58,9 +58,7 @@ final class Tests: XCTestCase {
58
58
59
59
func testBadStartup( ) {
60
60
class BadItem : LifecycleItem {
61
- var name : String {
62
- return " \( self ) "
63
- }
61
+ let label : String = UUID ( ) . uuidString
64
62
65
63
func start( callback: ( Error ? ) -> Void ) {
66
64
callback ( TestError ( ) )
@@ -84,9 +82,7 @@ final class Tests: XCTestCase {
84
82
85
83
func testBadShutdown( ) {
86
84
class BadItem : LifecycleItem {
87
- var name : String {
88
- return " \( self ) "
89
- }
85
+ let label : String = UUID ( ) . uuidString
90
86
91
87
func start( callback: ( Error ? ) -> Void ) {
92
88
callback ( nil )
@@ -117,9 +113,7 @@ final class Tests: XCTestCase {
117
113
self . semaphore = semaphore
118
114
}
119
115
120
- var name : String {
121
- return " \( self ) "
122
- }
116
+ let label : String = UUID ( ) . uuidString
123
117
124
118
func start( callback: ( Error ? ) -> Void ) {
125
119
self . state = . started
@@ -153,9 +147,7 @@ final class Tests: XCTestCase {
153
147
154
148
func testBadStartAndWait( ) {
155
149
class BadItem : LifecycleItem {
156
- var name : String {
157
- return " \( self ) "
158
- }
150
+ let label : String = UUID ( ) . uuidString
159
151
160
152
func start( callback: ( Error ? ) -> Void ) {
161
153
callback ( TestError ( ) )
@@ -183,8 +175,8 @@ final class Tests: XCTestCase {
183
175
self . result = result
184
176
}
185
177
186
- var name : String {
187
- return " \( self . id) "
178
+ var label : String {
179
+ return self . id
188
180
}
189
181
190
182
func start( callback: ( Error ? ) -> Void ) {
@@ -239,7 +231,7 @@ final class Tests: XCTestCase {
239
231
let lifecycle = Lifecycle ( )
240
232
let items = ( 0 ... Int . random ( in: 10 ... 20 ) ) . map { _ in Sync ( ) }
241
233
items. forEach { item in
242
- lifecycle. register ( name : item. id, start: item. start, shutdown: item. shutdown)
234
+ lifecycle. register ( label : item. id, start: item. start, shutdown: item. shutdown)
243
235
}
244
236
245
237
lifecycle. start ( configuration: . init( shutdownSignal: nil ) ) { error in
@@ -255,14 +247,14 @@ final class Tests: XCTestCase {
255
247
let lifecycle = Lifecycle ( )
256
248
257
249
let item1 = NIOItem ( eventLoopGroup: eventLoopGroup)
258
- lifecycle. register ( name : " item1 " , start: . eventLoopFuture( item1. start) , shutdown: . eventLoopFuture( item1. shutdown) )
250
+ lifecycle. register ( label : " item1 " , start: . eventLoopFuture( item1. start) , shutdown: . eventLoopFuture( item1. shutdown) )
259
251
260
- lifecycle. register ( name : " blocker " ,
252
+ lifecycle. register ( label : " blocker " ,
261
253
start: { ( ) -> Void in try eventLoopGroup. next ( ) . makeSucceededFuture ( ( ) ) . wait ( ) } ,
262
254
shutdown: { ( ) -> Void in try eventLoopGroup. next ( ) . makeSucceededFuture ( ( ) ) . wait ( ) } )
263
255
264
256
let item2 = NIOItem ( eventLoopGroup: eventLoopGroup)
265
- lifecycle. register ( name : " item2 " , start: . eventLoopFuture( item2. start) , shutdown: . eventLoopFuture( item2. shutdown) )
257
+ lifecycle. register ( label : " item2 " , start: . eventLoopFuture( item2. start) , shutdown: . eventLoopFuture( item2. shutdown) )
266
258
267
259
lifecycle. start ( configuration: . init( shutdownSignal: nil ) ) { error in
268
260
XCTAssertNil ( error, " not expecting error " )
@@ -315,7 +307,7 @@ final class Tests: XCTestCase {
315
307
let lifecycle = Lifecycle ( )
316
308
317
309
let item = Sync ( )
318
- lifecycle. register ( name : " test " ,
310
+ lifecycle. register ( label : " test " ,
319
311
start: item. start,
320
312
shutdown: item. shutdown)
321
313
@@ -349,7 +341,7 @@ final class Tests: XCTestCase {
349
341
let lifecycle = Lifecycle ( )
350
342
351
343
let item = Sync ( )
352
- lifecycle. registerShutdown ( name : " test " , item. shutdown)
344
+ lifecycle. registerShutdown ( label : " test " , item. shutdown)
353
345
354
346
lifecycle. start ( configuration: . init( shutdownSignal: nil ) ) { error in
355
347
XCTAssertNil ( error, " not expecting error " )
@@ -363,7 +355,7 @@ final class Tests: XCTestCase {
363
355
let lifecycle = Lifecycle ( )
364
356
365
357
let item = GoodItem ( )
366
- lifecycle. register ( name : " test " ,
358
+ lifecycle. register ( label : " test " ,
367
359
start: . async( item. start) ,
368
360
shutdown: . async( item. shutdown) )
369
361
@@ -379,7 +371,7 @@ final class Tests: XCTestCase {
379
371
let lifecycle = Lifecycle ( )
380
372
381
373
let item = GoodItem ( )
382
- lifecycle. registerShutdown ( name : " test " , . async( item. shutdown) )
374
+ lifecycle. registerShutdown ( label : " test " , . async( item. shutdown) )
383
375
384
376
lifecycle. start ( configuration: . init( shutdownSignal: nil ) ) { error in
385
377
XCTAssertNil ( error, " not expecting error " )
@@ -393,7 +385,7 @@ final class Tests: XCTestCase {
393
385
let lifecycle = Lifecycle ( )
394
386
395
387
let item = GoodItem ( )
396
- lifecycle. register ( name : " test " ,
388
+ lifecycle. register ( label : " test " ,
397
389
start: . async { callback in
398
390
print ( " start " )
399
391
item. start ( callback: callback)
@@ -415,7 +407,7 @@ final class Tests: XCTestCase {
415
407
let lifecycle = Lifecycle ( )
416
408
417
409
let item = GoodItem ( )
418
- lifecycle. registerShutdown ( name : " test " , . async { callback in
410
+ lifecycle. registerShutdown ( label : " test " , . async { callback in
419
411
print ( " shutdown " )
420
412
item. shutdown ( callback: callback)
421
413
} )
@@ -433,7 +425,7 @@ final class Tests: XCTestCase {
433
425
let lifecycle = Lifecycle ( )
434
426
435
427
let item = NIOItem ( eventLoopGroup: eventLoopGroup)
436
- lifecycle. register ( name : item. id,
428
+ lifecycle. register ( label : item. id,
437
429
start: . eventLoopFuture( item. start) ,
438
430
shutdown: . eventLoopFuture( item. shutdown) )
439
431
@@ -450,7 +442,7 @@ final class Tests: XCTestCase {
450
442
let lifecycle = Lifecycle ( )
451
443
452
444
let item = NIOItem ( eventLoopGroup: eventLoopGroup)
453
- lifecycle. registerShutdown ( name : item. id, . eventLoopFuture( item. shutdown) )
445
+ lifecycle. registerShutdown ( label : item. id, . eventLoopFuture( item. shutdown) )
454
446
455
447
lifecycle. start ( configuration: . init( shutdownSignal: nil ) ) { error in
456
448
XCTAssertNil ( error, " not expecting error " )
@@ -465,7 +457,7 @@ final class Tests: XCTestCase {
465
457
let lifecycle = Lifecycle ( )
466
458
467
459
let item = NIOItem ( eventLoopGroup: eventLoopGroup)
468
- lifecycle. register ( name : item. id,
460
+ lifecycle. register ( label : item. id,
469
461
start: . eventLoopFuture {
470
462
print ( " start " )
471
463
return item. start ( )
@@ -488,7 +480,7 @@ final class Tests: XCTestCase {
488
480
let lifecycle = Lifecycle ( )
489
481
490
482
let item = NIOItem ( eventLoopGroup: eventLoopGroup)
491
- lifecycle. registerShutdown ( name : item. id, . eventLoopFuture {
483
+ lifecycle. registerShutdown ( label : item. id, . eventLoopFuture {
492
484
print ( " shutdown " )
493
485
return item. shutdown ( )
494
486
} )
@@ -505,7 +497,7 @@ final class Tests: XCTestCase {
505
497
let eventLoopGroup = MultiThreadedEventLoopGroup ( numberOfThreads: System . coreCount)
506
498
let lifecycle = Lifecycle ( )
507
499
508
- lifecycle. register ( name : " test " ,
500
+ lifecycle. register ( label : " test " ,
509
501
start: . eventLoopFuture { eventLoopGroup. next ( ) . makeFailedFuture ( TestError ( ) ) } ,
510
502
shutdown: . eventLoopFuture { eventLoopGroup. next ( ) . makeSucceededFuture ( ( ) ) } )
511
503
@@ -545,7 +537,7 @@ final class Tests: XCTestCase {
545
537
let expectedData = UUID ( ) . uuidString
546
538
let item = Item ( expectedData)
547
539
let lifecycle = Lifecycle ( )
548
- lifecycle. register ( name : " test " ,
540
+ lifecycle. register ( label : " test " ,
549
541
start: . eventLoopFuture {
550
542
item. start ( ) . map { data -> Void in
551
543
state = . started( data)
@@ -580,9 +572,7 @@ private class GoodItem: LifecycleItem {
580
572
self . shutdownDelay = shutdownDelay
581
573
}
582
574
583
- var name : String {
584
- return " \( GoodItem . self) "
585
- }
575
+ let label : String = UUID ( ) . uuidString
586
576
587
577
func start( callback: @escaping ( Error ? ) -> Void ) {
588
578
self . queue. asyncAfter ( deadline: . now( ) + self . startDelay) {
0 commit comments