@@ -49,42 +49,40 @@ const captureProcessResult = (
4949 ) ;
5050
5151describe ( "VcsProcess.run" , ( ) => {
52- it . effect ( "bounds a synthetic burst of GitHub API processes" , ( ) =>
52+ it . effect ( "bounds a synthetic burst of GitHub API processes across service instances " , ( ) =>
5353 Effect . gen ( function * ( ) {
5454 const gate = yield * Deferred . make < void > ( ) ;
5555 const starts = yield * Queue . unbounded < number > ( ) ;
5656 const active = yield * Ref . make ( 0 ) ;
5757 const peak = yield * Ref . make ( 0 ) ;
5858 const total = yield * Ref . make ( 0 ) ;
59- const service = yield * VcsProcess . make . pipe (
60- Effect . provideService (
61- ProcessRunner . ProcessRunner ,
62- ProcessRunner . ProcessRunner . of ( {
63- run : ( ) =>
64- Effect . gen ( function * ( ) {
65- const count = yield * Ref . updateAndGet ( active , ( held ) => held + 1 ) ;
66- yield * Ref . update ( peak , ( held ) => Math . max ( held , count ) ) ;
67- yield * Ref . update ( total , ( held ) => held + 1 ) ;
68- yield * Queue . offer ( starts , count ) ;
69- yield * Deferred . await ( gate ) ;
70- return {
71- stdout : "" ,
72- stderr : "" ,
73- code : ChildProcessSpawner . ExitCode ( 0 ) ,
74- timedOut : false ,
75- stdoutTruncated : false ,
76- stderrTruncated : false ,
77- stdoutInvalidUtf8 : false ,
78- stderrInvalidUtf8 : false ,
79- } ;
80- } ) . pipe ( Effect . ensuring ( Ref . update ( active , ( count ) => count - 1 ) ) ) ,
81- } ) ,
82- ) ,
83- ) ;
59+ const processRunner = ProcessRunner . ProcessRunner . of ( {
60+ run : ( ) =>
61+ Effect . gen ( function * ( ) {
62+ const count = yield * Ref . updateAndGet ( active , ( held ) => held + 1 ) ;
63+ yield * Ref . update ( peak , ( held ) => Math . max ( held , count ) ) ;
64+ yield * Ref . update ( total , ( held ) => held + 1 ) ;
65+ yield * Queue . offer ( starts , count ) ;
66+ yield * Deferred . await ( gate ) ;
67+ return {
68+ stdout : "" ,
69+ stderr : "" ,
70+ code : ChildProcessSpawner . ExitCode ( 0 ) ,
71+ timedOut : false ,
72+ stdoutTruncated : false ,
73+ stderrTruncated : false ,
74+ stdoutInvalidUtf8 : false ,
75+ stderrInvalidUtf8 : false ,
76+ } ;
77+ } ) . pipe ( Effect . ensuring ( Ref . update ( active , ( count ) => count - 1 ) ) ) ,
78+ } ) ;
79+ const services = yield * Effect . all ( [ VcsProcess . make , VcsProcess . make ] , {
80+ concurrency : "unbounded" ,
81+ } ) . pipe ( Effect . provideService ( ProcessRunner . ProcessRunner , processRunner ) ) ;
8482
8583 const burst = yield * Effect . all (
8684 Array . from ( { length : 32 } , ( _ , index ) =>
87- service . run ( {
85+ services [ index % services . length ] ! . run ( {
8886 operation : `synthetic.github.${ index } ` ,
8987 command : "gh" ,
9088 args : [ "api" , "user" ] ,
0 commit comments