github.com/yandex/pandora@v0.5.32/components/guns/grpc/scenario/ammo.go (about)

     1  package scenario
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/golang/protobuf/proto"
     7  	"github.com/yandex/pandora/components/providers/scenario"
     8  )
     9  
    10  type SourceStorage interface {
    11  	Variables() map[string]any
    12  }
    13  
    14  type Scenario struct {
    15  	id              uint64
    16  	Calls           []Call
    17  	Name            string
    18  	MinWaitingTime  time.Duration
    19  	VariableStorage SourceStorage
    20  }
    21  
    22  func (a *Scenario) SetID(id uint64) {
    23  	a.id = id
    24  }
    25  
    26  func (a *Scenario) Clone() scenario.ProvAmmo {
    27  	return &Scenario{
    28  		Calls:           a.Calls,
    29  		Name:            a.Name,
    30  		MinWaitingTime:  a.MinWaitingTime,
    31  		VariableStorage: a.VariableStorage,
    32  	}
    33  }
    34  
    35  type Call struct {
    36  	Name           string
    37  	Preprocessors  []Preprocessor
    38  	Postprocessors []Postprocessor
    39  
    40  	Tag      string            `json:"tag"`
    41  	Call     string            `json:"call"`
    42  	Metadata map[string]string `json:"metadata"`
    43  	Payload  []byte            `json:"payload"`
    44  
    45  	Sleep time.Duration `json:"sleep"`
    46  }
    47  
    48  type Postprocessor interface {
    49  	Process(out proto.Message, code int) (map[string]any, error)
    50  }
    51  
    52  type Preprocessor interface {
    53  	Process(call *Call, templateVars map[string]any) (newVars map[string]any, err error)
    54  }