Debian Codegraph @

stress/v2/statement/go.go

raw symbols SCIP
1 package statement
2
3 import (
4 "fmt"
5 "time"
6
7 "github.com/influxdata/influxdb/stress/v2/stress_client"
8 )
9
10 // GoStatement is a Statement Implementation to allow other statements to be run concurrently
11 type GoStatement struct {
12 Statement
13
14 StatementID string
15 }
16
17 // SetID statisfies the Statement Interface
18 func (i *GoStatement) SetID(s string) {
19 i.StatementID = s
20 }
21
22 // Run statisfies the Statement Interface
23 func (i *GoStatement) Run(s *stressClient.StressTest) {
24 // TODO: remove
25 switch i.Statement.(type) {
26 case *QueryStatement:
27 time.Sleep(1 * time.Second)
28 }
29
30 s.Add(1)
31 go func() {
32 i.Statement.Run(s)
33 s.Done()
34 }()
35 }
36
37 // Report statisfies the Statement Interface
38 func (i *GoStatement) Report(s *stressClient.StressTest) string {
39 return fmt.Sprintf("Go %v", i.Statement.Report(s))
40 }