Debian Codegraph @

stress/v2/statement/set.go

raw symbols SCIP
1 package statement
2
3 import (
4 "fmt"
5 "strings"
6
7 "github.com/influxdata/influxdb/stress/v2/stress_client"
8 )
9
10 // SetStatement set state variables for the test
11 type SetStatement struct {
12 Var string
13 Value string
14
15 StatementID string
16
17 Tracer *stressClient.Tracer
18 }
19
20 // SetID statisfies the Statement Interface
21 func (i *SetStatement) SetID(s string) {
22 i.StatementID = s
23 }
24
25 // Run statisfies the Statement Interface
26 func (i *SetStatement) Run(s *stressClient.StressTest) {
27 i.Tracer = stressClient.NewTracer(make(map[string]string))
28 d := stressClient.NewDirective(strings.ToLower(i.Var), strings.ToLower(i.Value), i.Tracer)
29 switch d.Property {
30 // Needs to be set on both StressTest and stressClient
31 // Set the write percison for points generated
32 case "precision":
33 s.Precision = d.Value
34 i.Tracer.Add(1)
35 s.SendDirective(d)
36 // Lives on StressTest
37 // Set the date for the first point entered into the database
38 case "startdate":
39 s.Lock()
40 s.StartDate = d.Value
41 s.Unlock()
42 // Lives on StressTest
43 // Set the BatchSize for writes
44 case "batchsize":
45 s.Lock()
46 s.BatchSize = parseInt(d.Value)
47 s.Unlock()
48 // All other variables live on stressClient
49 default:
50 i.Tracer.Add(1)
51 s.SendDirective(d)
52 }
53 i.Tracer.Wait()
54 }
55
56 // Report statisfies the Statement Interface
57 func (i *SetStatement) Report(s *stressClient.StressTest) string {
58 return fmt.Sprintf("SET %v = '%v'", i.Var, i.Value)
59 }