Skip to content

Commit

Permalink
grpc timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Lack30 committed Mar 22, 2024
1 parent 8815727 commit 610f7ea
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion executor/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (

const (
DefaultCacheSize = 1024 * 1024
DefaultDialTimeout = time.Second * 15
DefaultDialTimeout = time.Minute * 3
DefaultExecTimeout = time.Minute * 10
)

const (
Expand Down Expand Up @@ -162,12 +163,14 @@ type ExecOptions struct {
Root string
Args []string
Environments map[string]string
Timeout time.Duration
}

func NewExecOptions() *ExecOptions {
opt := &ExecOptions{
Context: context.TODO(),
Environments: map[string]string{},
Timeout: DefaultExecTimeout,
}
return opt
}
Expand Down Expand Up @@ -195,6 +198,12 @@ func ExecWithEnv(key, value string) ExecOption {
}
}

func ExecWithTimeout(timeout time.Duration) ExecOption {
return func(options *ExecOptions) {
options.Timeout = timeout
}
}

// ExecWithValue set key-value at options.Context
func ExecWithValue(key string, value any) ExecOption {
return func(options *ExecOptions) {
Expand Down

0 comments on commit 610f7ea

Please sign in to comment.