-
Notifications
You must be signed in to change notification settings - Fork 2
/
params.go
57 lines (44 loc) · 1.78 KB
/
params.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package gopiston
import "time"
// Function to pass the Params struct.
type Param func(*Params)
// Struct that contains all piston parameters.
type Params struct {
requestBody *RequestBody
}
// Stdin (optional) The text to pass as stdin to the program. Must be a string or left out. Defaults to blank string.
func Stdin(input string) Param {
return func(param *Params) {
param.requestBody.Stdin = input
}
}
// Args (optional) The arguments to pass to the program. Must be an array or left out. Defaults to [].
func Args(args []string) Param {
return func(param *Params) {
param.requestBody.Args = args
}
}
// CompileTimeout (optional) The maximum time allowed for the compile stage to finish before bailing out in milliseconds. Must be a "time.Duration" object. Defaults to 10 seconds.
func CompileTimeout(timeout time.Duration) Param {
return func(param *Params) {
param.requestBody.CompileTimeout = int(timeout.Seconds())
}
}
// RunTimeout (optional) The maximum time allowed for the run stage to finish before bailing out in milliseconds. Must be a "time.Duration" object. Defaults to 3 seconds.
func RunTimeout(timeout time.Duration) Param {
return func(param *Params) {
param.requestBody.RunTimeout = int(timeout.Seconds())
}
}
// CompileMemoryLimit (optional) The maximum amount of memory the compile stage is allowed to use in bytes. Must be a number or left out. Defaults to -1 (no limit)
func CompileMemoryLimit(limit int) Param {
return func(param *Params) {
param.requestBody.CompileMemoryLimit = limit
}
}
// RunMemoryLimit (optional) The maximum amount of memory the run stage is allowed to use in bytes. Must be a number or left out. Defaults to -1 (no limit)
func RunMemoryLimit(limit int) Param {
return func(param *Params) {
param.requestBody.RunMemoryLimit = limit
}
}