Skip to content

Commit 45383ff

Browse files
committed
Add control for number of parallel requests
1 parent c8cd6ba commit 45383ff

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

Diff for: components/BatchDialog.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ import ActionButton from './ActionButton';
1111
import OutputFieldsChooser from './OutputFieldsChooser';
1212
import ProgressBar from './ProgressBar';
1313
import DelaySelector from './DelaySelector';
14+
import ParallelSelector from './ParallelSelector';
1415

1516
export default function BatchDialog({context, request}) {
1617
const [csvPath, setCsvPath] = useState("");
1718
const [csvHeaders, setCsvHeaders] = useState([]);
1819
const [csvData, setCsvData] = useState([]);
1920
const [outputConfig, setOutputConfig] = useState([]);
2021
const [sent, setSent] = useState(0);
22+
2123
const [delay, setDelay] = useState(0);
24+
const [parallelism, setParallelism] = useState(1);
2225

2326
// Load default delay from plugin settings on mount
2427
useEffect(() => {
@@ -47,7 +50,7 @@ export default function BatchDialog({context, request}) {
4750
setSent(0);
4851

4952
const queue = new Queue({
50-
concurrent: 4,
53+
concurrent: parallelism,
5154
interval: 0,
5255
start: false,
5356
});
@@ -89,10 +92,11 @@ export default function BatchDialog({context, request}) {
8992

9093
<FormRow label="Run config">
9194
<DelaySelector value={delay} onChange={onChangeDelay}/>
95+
<ParallelSelector value={parallelism} onChange={({target: {value}}) => setParallelism(value)}/>
9296
</FormRow>
9397

9498
<FormRow label="Progress">
95-
<ProgressBar bgcolor="#a11" completed={sent * 100 / totalRequests} text={`${sent}/${totalRequests}`} />
99+
<ProgressBar bgcolor="#ff6b6b" completed={sent * 100 / totalRequests} text={`${sent}/${totalRequests}`} />
96100
</FormRow>
97101

98102
<ActionButton title="Run!" icon="fa-person-running" onClick={onRun} disabled={!canRun}/>

Diff for: components/ParallelSelector.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export default function ParallelSelector({value, onChange}) {
2+
return <label>
3+
Parallel requests
4+
<input
5+
type="number"
6+
step="1"
7+
min="1"
8+
value={value}
9+
onChange={onChange}
10+
/>
11+
</label>
12+
}

Diff for: components/ProgressBar.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ export default function ProgressBar(props) {
2626

2727
const labelStyles = {
2828
paddingInline: 5,
29-
color: 'white',
30-
fontWeight: 'bold'
29+
color: 'black',
30+
fontWeight: 'bold',
31+
fontSize: 'x-small',
32+
verticalAlign: 'top',
3133
}
3234

3335
return (

0 commit comments

Comments
 (0)