やあ@アンドリュートカール、 提案ありがとう! ご要望を承りましたので、検討させていただきます。
@アンドリュートカール、開発者はこれを共有しました:
現在、ユーザーは HTTP Request with Send(asnyc) を使用して、JSL promise を返すスクリプトを作成できます。 彼らは、同時接続になるプロミスの数を追跡できます。
promise が (onResult または onError で) 終了すると、さらにリクエストをキューに入れることができます。
によって共有される HTTP リクエストと JSL Promises を使用して、最大同時 HTTP リクエストを処理する例を次に示します。 @ブライアン_ブーン:
Names Default To Here( 1 );
//populate the requests
requests = {};
promises = {};
count = 100;
max = 30;
For(i = 1, i <= count, i++,
request = New HTTP Request( //this is the HTTP Request for the Query String Example in the SI
url( "http://httpbin.org/get" ),
Method( "GET" ),
Query String( [["username" => "bob", "address" => "12345", "count"=>i]] )
);
InsertInto(requests, request);
);
//now send them async
process_result = Function( {p, r},
//Show(p);
//Show( r );
if(N Items(promises),
RemoveFrom(promises, 1);
);
);
process_error = Function( {p, e, t},
//Show(p);
//Show( e );
//Show( t );
if(N Items(promises),
RemoveFrom(promises, 1);
);
);
while(N Items(requests),
count = max - N Items(promises);
if(count > N Items(requests),
count = N Items(requests);
);
Show(count);
For(i = 1, i <= count, i++,
request = requests[1];
RemoveFrom(requests, 1);
promise = request << Send( "async" );
InsertInto(promises, promise);
promise << On Result( process_result );
promise << On Error( process_error );
);
If(Nitems(promises),
wait(0);
);
);
//catch any stragglers
while(Nitems(promises),
wait(0);
);
Write("\!nDone!!!\!n");@アンドリュートカール、します@ブライアン_ブーンの応答はこの要求を満たしますか?
@mia_stephensはい、そうです。ご協力いただきありがとうございます。
確認していただいてありがとうございます@アンドリュートカール.これを配達済みとしてマークします。
同時 HTTP 呼び出しの数を制限します。
このようなもの
custom_multi_http = Function( {mm, max = 30},
//mm=multi_http_requests;
//max=5;
res = {};
status = {};
mm_get = mm << get requests;
chunks = Ceiling( N Items( mm_get ) / max );
chunk_list = {};
For( i = 1, i <= chunks, i++,
chunk_i = New Multi HTTP Request();
For( j = 1 + (i - 1) * max, j <= Min( max * i, N Items( mm_get ) ), j++,
chunk_i << Add( mm_get[j] )
);
Wait( 0 );
chunk_i_requests = chunk_i << get requests;
Insert Into( res, chunk_i << Send() );
Insert Into( status, chunk_i_requests << get status() );
);
Return( res, status );
);