mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 07:26:55 +08:00
change: use context to contral ScreenRecord timeout or cancel
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user