change: use context to contral ScreenRecord timeout or cancel

This commit is contained in:
lilong.129
2025-03-06 22:16:49 +08:00
parent e8025f9e65
commit 0d416e74a1
7 changed files with 126 additions and 27 deletions
+11
View File
@@ -1,12 +1,14 @@
package option
import (
"context"
"math/rand/v2"
"github.com/httprunner/httprunner/v5/internal/builtin"
)
type ActionOptions struct {
Context context.Context
// log
Identifier string `json:"identifier,omitempty" yaml:"identifier,omitempty"` // used to identify the action in log
@@ -33,6 +35,9 @@ func (o *ActionOptions) Options() []ActionOption {
return options
}
if o.Context != nil {
options = append(options, WithContext(o.Context))
}
if o.Identifier != "" {
options = append(options, WithIdentifier(o.Identifier))
}
@@ -206,6 +211,12 @@ func NewActionOptions(opts ...ActionOption) *ActionOptions {
type ActionOption func(o *ActionOptions)
func WithContext(ctx context.Context) ActionOption {
return func(o *ActionOptions) {
o.Context = ctx
}
}
func WithCustomOption(key string, value interface{}) ActionOption {
return func(o *ActionOptions) {
if o.Custom == nil {
+3 -1
View File
@@ -1,6 +1,8 @@
package option
import "github.com/httprunner/httprunner/v5/uixt/types"
import (
"github.com/httprunner/httprunner/v5/uixt/types"
)
type ScreenOptions struct {
ScreenShotOptions