Skip to content

Commit 8bcd840

Browse files
johnmccabealexellis
authored andcommitted
Change all references to Hard timeout to Exec timeout
This commit updates all references to a Hard timeout, replacing it with Exec timeout for consistency with the existing Watchdog where `exec_timeout` is used. Signed-off-by: John McCabe <[email protected]>
1 parent 3e0d53a commit 8bcd840

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ HTTP headers cannot be sent after function starts executing due to input/output
2626

2727
* A static Content-type can be set ahead of time.
2828

29-
* Hard timeout: supported.
29+
* Exec timeout: supported.
3030

3131
### 2. Afterburn (mode=afterburn)
3232

@@ -40,7 +40,7 @@ Vastly accelerated processing speed but requires a client library for each langu
4040

4141
* A dynamic Content-type can be set from the client library.
4242

43-
* Hard timeout: not supported.
43+
* Exec timeout: not supported.
4444

4545
Example client libraries:
4646

@@ -98,7 +98,7 @@ Reads entire request into memory from the HTTP request. At this point we seriali
9898

9999
* A static Content-type can be set ahead of time.
100100

101-
* Hard timeout: supported.
101+
* Exec timeout: supported.
102102

103103
## Configuration
104104

@@ -109,7 +109,7 @@ Environmental variables:
109109
| `function_process` | Yes | The process to invoke for each function call function process (alias - fprocess). This must be a UNIX binary and accept input via STDIN and output via STDOUT. |
110110
| `read_timeout` | Yes | HTTP timeout for reading the payload from the client caller (in seconds) |
111111
| `write_timeout` | Yes | HTTP timeout for writing a response body from your function (in seconds) |
112-
| `hard_timeout` | Yes | Hard timeout for process exec'd for each incoming request (in seconds). Disabled if set to 0. |
112+
| `exec_timeout` | Yes | Exec timeout for process exec'd for each incoming request (in seconds). Disabled if set to 0. |
113113
| `port` | Yes | Specify an alternative TCP port fo testing |
114114
| `write_debug` | No | Write all output, error messages, and additional information to the logs. Default is false. |
115115
| `content_type` | Yes | Force a specific Content-Type response for all responses - only in forking/serializing modes. |

config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type WatchdogConfig struct {
1212
TCPPort int
1313
HTTPReadTimeout time.Duration
1414
HTTPWriteTimeout time.Duration
15-
HardTimeout time.Duration
15+
ExecTimeout time.Duration
1616

1717
FunctionProcess string
1818
ContentType string
@@ -56,7 +56,7 @@ func New(env []string) (WatchdogConfig, error) {
5656
HTTPWriteTimeout: getDuration(envMap, "write_timeout", time.Second*10),
5757
FunctionProcess: functionProcess,
5858
InjectCGIHeaders: true,
59-
HardTimeout: getDuration(envMap, "hard_timeout", time.Second*10),
59+
ExecTimeout: getDuration(envMap, "exec_timeout", time.Second*10),
6060
OperationalMode: ModeStreaming,
6161
ContentType: contentType,
6262
}

config/config_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,37 +116,37 @@ func Test_Timeouts(t *testing.T) {
116116
cases := []struct {
117117
readTimeout time.Duration
118118
writeTimeout time.Duration
119-
hardTimeout time.Duration
119+
execTimeout time.Duration
120120
env []string
121121
name string
122122
}{
123123
{
124124
name: "Defaults",
125125
readTimeout: time.Second * 10,
126126
writeTimeout: time.Second * 10,
127-
hardTimeout: time.Second * 10,
127+
execTimeout: time.Second * 10,
128128
env: []string{},
129129
},
130130
{
131131
name: "Custom read-timeout",
132132
readTimeout: time.Second * 5,
133133
writeTimeout: time.Second * 10,
134-
hardTimeout: time.Second * 10,
134+
execTimeout: time.Second * 10,
135135
env: []string{"read_timeout=5s"},
136136
},
137137
{
138138
name: "Custom write-timeout",
139139
readTimeout: time.Second * 10,
140140
writeTimeout: time.Second * 5,
141-
hardTimeout: time.Second * 10,
141+
execTimeout: time.Second * 10,
142142
env: []string{"write_timeout=5s"},
143143
},
144144
{
145-
name: "Custom hard-timeout",
145+
name: "Custom exec-timeout",
146146
readTimeout: time.Second * 10,
147147
writeTimeout: time.Second * 10,
148-
hardTimeout: time.Second * 5,
149-
env: []string{"hard_timeout=5s"},
148+
execTimeout: time.Second * 5,
149+
env: []string{"exec_timeout=5s"},
150150
},
151151
}
152152

@@ -161,8 +161,8 @@ func Test_Timeouts(t *testing.T) {
161161
if testCase.writeTimeout != actual.HTTPWriteTimeout {
162162
t.Errorf("(%s) HTTPWriteTimeout want: %s, got: %s", testCase.name, actual.HTTPWriteTimeout, testCase.writeTimeout)
163163
}
164-
if testCase.hardTimeout != actual.HardTimeout {
165-
t.Errorf("(%s) HardTimeout want: %s, got: %s", testCase.name, actual.HardTimeout, testCase.hardTimeout)
164+
if testCase.execTimeout != actual.ExecTimeout {
165+
t.Errorf("(%s) ExecTimeout want: %s, got: %s", testCase.name, actual.ExecTimeout, testCase.execTimeout)
166166
}
167167

168168
}

functions/serializing_fork_runner.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
// SerializingForkFunctionRunner forks a process for each invocation
1414
type SerializingForkFunctionRunner struct {
15-
HardTimeout time.Duration
15+
ExecTimeout time.Duration
1616
}
1717

1818
// Run run a fork for each invocation
@@ -43,17 +43,17 @@ func serializeFunction(req FunctionRequest, f *SerializingForkFunctionRunner) (*
4343
cmd.Env = req.Environment
4444

4545
var timer *time.Timer
46-
if f.HardTimeout > time.Millisecond*0 {
46+
if f.ExecTimeout > time.Millisecond*0 {
4747
log.Println("Started a timer.")
4848

49-
timer = time.NewTimer(f.HardTimeout)
49+
timer = time.NewTimer(f.ExecTimeout)
5050
go func() {
5151
<-timer.C
5252

53-
log.Printf("Function was killed by HardTimeout: %s\n", f.HardTimeout)
53+
log.Printf("Function was killed by ExecTimeout: %s\n", f.ExecTimeout)
5454
killErr := cmd.Process.Kill()
5555
if killErr != nil {
56-
log.Println("Error killing function due to HardTimeout", killErr)
56+
log.Println("Error killing function due to ExecTimeout", killErr)
5757
}
5858
}()
5959
}

functions/streaming_runner.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type FunctionRequest struct {
2626

2727
// ForkFunctionRunner forks a process for each invocation
2828
type ForkFunctionRunner struct {
29-
HardTimeout time.Duration
29+
ExecTimeout time.Duration
3030
}
3131

3232
// Run run a fork for each invocation
@@ -37,16 +37,16 @@ func (f *ForkFunctionRunner) Run(req FunctionRequest) error {
3737
cmd.Env = req.Environment
3838

3939
var timer *time.Timer
40-
if f.HardTimeout > time.Millisecond*0 {
41-
timer = time.NewTimer(f.HardTimeout)
40+
if f.ExecTimeout > time.Millisecond*0 {
41+
timer = time.NewTimer(f.ExecTimeout)
4242

4343
go func() {
4444
<-timer.C
4545

46-
fmt.Printf("Function was killed by HardTimeout: %d\n", f.HardTimeout)
46+
fmt.Printf("Function was killed by ExecTimeout: %d\n", f.ExecTimeout)
4747
killErr := cmd.Process.Kill()
4848
if killErr != nil {
49-
fmt.Println("Error killing function due to HardTimeout", killErr)
49+
fmt.Println("Error killing function due to ExecTimeout", killErr)
5050
}
5151
}()
5252
}

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func makeAfterBurnRequestHandler(watchdogConfig config.WatchdogConfig) func(http
110110

111111
func makeSerializingForkRequestHandler(watchdogConfig config.WatchdogConfig) func(http.ResponseWriter, *http.Request) {
112112
functionInvoker := functions.SerializingForkFunctionRunner{
113-
HardTimeout: watchdogConfig.HardTimeout,
113+
ExecTimeout: watchdogConfig.ExecTimeout,
114114
}
115115

116116
return func(w http.ResponseWriter, r *http.Request) {
@@ -141,7 +141,7 @@ func makeSerializingForkRequestHandler(watchdogConfig config.WatchdogConfig) fun
141141

142142
func makeForkRequestHandler(watchdogConfig config.WatchdogConfig) func(http.ResponseWriter, *http.Request) {
143143
functionInvoker := functions.ForkFunctionRunner{
144-
HardTimeout: watchdogConfig.HardTimeout,
144+
ExecTimeout: watchdogConfig.ExecTimeout,
145145
}
146146

147147
return func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)