Sometimes in your application, you may want to introduce a delay in your requests. This may be to avoid hitting rate limits or to avoid overloading a development environment. With Saloon, you may use the delay method on either your connector or request. With this method, you can set a delay in milliseconds.
<?php$forge =newForgeConnector;// Delay every request sent with the ForgeConnector by 500ms $forge->delay()->set(500);
<?php$request =newGetServersRequest;// Delay just this request instance by 500ms$request->delay()->set(500);
If you have defined the delay on both the connector and the request, the request delay will take priority.
Default Delay
You may also wish to define a default delay on your connector or request. You can do this by extending the defaultDelay method.
<?phpclassForgeConnectorextendsConnector{// {...}// Every request sent through this connector will have a 500ms delay.protectedfunctiondefaultDelay():?int {return500; }}
<?phpclassGetServersRequestextendsRequest{// {...}// Every time this request is sent, a 500ms delay is addedprotectedfunctiondefaultDelay():?int {return500; }}