Skip to content

Commit 0a5c0f6

Browse files
committed
feat: add execution timeout
1 parent 2f39681 commit 0a5c0f6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ You can execute the SQL Loader command using the `execute` method.
154154
$loader->execute();
155155
```
156156

157+
You can also set the execution timeout in seconds. Default is 3600 seconds / 1 hr.
158+
159+
```php
160+
$loader->execute(60);
161+
```
162+
157163
### Execution Result
158164

159165
You can check if the execution was successful using the `successfull` method.

src/SQLLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function into(
9999
/**
100100
* Execute SQL Loader command.
101101
*/
102-
public function execute(): ProcessResult
102+
public function execute(int $timeout = 3600): ProcessResult
103103
{
104104
if (! $this->tables) {
105105
throw new InvalidArgumentException('At least one table definition is required.');
@@ -109,7 +109,7 @@ public function execute(): ProcessResult
109109
throw new InvalidArgumentException('Input file is required.');
110110
}
111111

112-
$this->result = Process::run($this->buildCommand());
112+
$this->result = Process::timeout($timeout)->run($this->buildCommand());
113113

114114
if ($this->deleteFiles) {
115115
if ($this->logPath && File::exists($this->logPath)) {

0 commit comments

Comments
 (0)