NewRunner returns new benchmarking runner.
(cfg Config)
| 54 | |
| 55 | // NewRunner returns new benchmarking runner. |
| 56 | func NewRunner(cfg Config) (*Runner, error) { |
| 57 | if err := validateConfig(cfg); err != nil { |
| 58 | return nil, err |
| 59 | } |
| 60 | |
| 61 | if cfg.NumOperations == 0 { |
| 62 | cfg.NumOperations = 1 |
| 63 | } |
| 64 | |
| 65 | indexer, err := esutil.NewBulkIndexer( |
| 66 | esutil.BulkIndexerConfig{ |
| 67 | Client: cfg.ReportClient, |
| 68 | Index: statsIndex, |
| 69 | FlushBytes: 2e+6, |
| 70 | FlushInterval: 15 * time.Second, |
| 71 | OnError: func(ctx context.Context, err error) { errs = append(errs, err) }, |
| 72 | }, |
| 73 | ) |
| 74 | if err != nil { |
| 75 | return nil, fmt.Errorf("cannot create bulk indexer: %w", err) |
| 76 | } |
| 77 | |
| 78 | return &Runner{ |
| 79 | config: cfg, |
| 80 | indexer: indexer, |
| 81 | }, nil |
| 82 | } |
| 83 | |
| 84 | // Runner represents the benchmarking runner. |
| 85 | type Runner struct { |
nothing calls this directly
no test coverage detected