-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Similarly to benchmark rally command, generate schema-b documents for a given integration. Instead of creating a rally track out of them we will stream them, according to a configurable rate, directly to an ES cluster, using bulk requets
- Loading branch information
Andrea Spacca
authored
Dec 8, 2023
1 parent
a5c8a8e
commit f075590
Showing
6 changed files
with
1,024 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package stream | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/elastic/elastic-package/internal/elasticsearch" | ||
"github.com/elastic/elastic-package/internal/kibana" | ||
"github.com/elastic/elastic-package/internal/profile" | ||
) | ||
|
||
// Options contains benchmark runner options. | ||
type Options struct { | ||
ESAPI *elasticsearch.API | ||
KibanaClient *kibana.Client | ||
BenchName string | ||
BackFill time.Duration | ||
EventsPerPeriod uint64 | ||
PeriodDuration time.Duration | ||
PerformCleanup bool | ||
TimestampField string | ||
PackageRootPath string | ||
Variant string | ||
Profile *profile.Profile | ||
} | ||
|
||
type ClientOptions struct { | ||
Host string | ||
Username string | ||
Password string | ||
} | ||
type OptionFunc func(*Options) | ||
|
||
func NewOptions(fns ...OptionFunc) Options { | ||
var opts Options | ||
for _, fn := range fns { | ||
fn(&opts) | ||
} | ||
return opts | ||
} | ||
|
||
func WithESAPI(api *elasticsearch.API) OptionFunc { | ||
return func(opts *Options) { | ||
opts.ESAPI = api | ||
} | ||
} | ||
|
||
func WithKibanaClient(c *kibana.Client) OptionFunc { | ||
return func(opts *Options) { | ||
opts.KibanaClient = c | ||
} | ||
} | ||
|
||
func WithPackageRootPath(path string) OptionFunc { | ||
return func(opts *Options) { | ||
opts.PackageRootPath = path | ||
} | ||
} | ||
|
||
func WithBenchmarkName(name string) OptionFunc { | ||
return func(opts *Options) { | ||
opts.BenchName = name | ||
} | ||
} | ||
|
||
func WithVariant(name string) OptionFunc { | ||
return func(opts *Options) { | ||
opts.Variant = name | ||
} | ||
} | ||
|
||
func WithProfile(p *profile.Profile) OptionFunc { | ||
return func(opts *Options) { | ||
opts.Profile = p | ||
} | ||
} | ||
|
||
func WithBackFill(d time.Duration) OptionFunc { | ||
return func(opts *Options) { | ||
opts.BackFill = -1 * d | ||
} | ||
} | ||
|
||
func WithEventsPerPeriod(e uint64) OptionFunc { | ||
return func(opts *Options) { | ||
opts.EventsPerPeriod = e | ||
} | ||
} | ||
|
||
func WithPeriodDuration(d time.Duration) OptionFunc { | ||
return func(opts *Options) { | ||
opts.PeriodDuration = d | ||
} | ||
} | ||
|
||
func WithPerformCleanup(p bool) OptionFunc { | ||
return func(opts *Options) { | ||
opts.PerformCleanup = p | ||
} | ||
} | ||
|
||
func WithTimestampField(t string) OptionFunc { | ||
return func(opts *Options) { | ||
opts.TimestampField = t | ||
} | ||
} |
Oops, something went wrong.