Skip to content

Commit

Permalink
basic pyrobench cli using its own config.go
Browse files Browse the repository at this point in the history
  • Loading branch information
eh-am committed Aug 31, 2021
1 parent 8841206 commit a0659df
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
3 changes: 1 addition & 2 deletions benchmark/cmd/command/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
goexec "os/exec"

"github.com/mitchellh/mapstructure"
// benchCfg "github.com/pyroscope-io/pyroscope/benchmark/config"
"github.com/pyroscope-io/pyroscope/pkg/config"
"github.com/pyroscope-io/pyroscope/benchmark/config"
"github.com/pyroscope-io/pyroscope/pkg/util/bytesize"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
Expand Down
7 changes: 2 additions & 5 deletions benchmark/cmd/command/loadgen.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package command

import (
// benchConfig "github.com/pyroscope-io/pyroscope/benchmark/config"
"github.com/pyroscope-io/pyroscope/pkg/config"
"github.com/pyroscope-io/pyroscope/benchmark/config"
"github.com/spf13/cobra"
)

func newLoadGen(cfg *config.Bench) *cobra.Command {
func newLoadGen(cfg *config.Config) *cobra.Command {
vpr := newViper()
loadgenCmd := &cobra.Command{
Use: "loadgen [flags]",
Short: "Generates load",
RunE: createCmdRunFn(cfg, vpr, false, func(cmd *cobra.Command, args []string, logger config.LoggerFunc) error {
return nil
// return cli.StartServer(cfg)
}),
}

// cli.PopulateFlagSet(cfg, loadgenCmd.Flags(), vpr, cli.WithSkip("metric-export-rules"))
return loadgenCmd
}
4 changes: 2 additions & 2 deletions benchmark/cmd/command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"runtime"
"strings"

"github.com/pyroscope-io/pyroscope/pkg/config"
"github.com/pyroscope-io/pyroscope/benchmark/config"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand All @@ -26,7 +26,7 @@ func Initialize() error {
rootCmd := newRootCmd(&cfg)
rootCmd.SilenceErrors = true
rootCmd.AddCommand(
newLoadGen(&cfg.Bench),
newLoadGen(&cfg),
)

logrus.SetReportCaller(true)
Expand Down
9 changes: 9 additions & 0 deletions benchmark/config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package config

type Config struct {
Version bool `mapstructure:"version"`
}

type LoggerFunc func(s string)
type LoggerConfiger interface{ InitializeLogging() LoggerFunc }
type FileConfiger interface{ ConfigFilePath() string }
4 changes: 0 additions & 4 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type Config struct {
Convert Convert `skip:"true" mapstructure:",squash"`
Exec Exec `skip:"true" mapstructure:",squash"`
DbManager DbManager `skip:"true" mapstructure:",squash"`
Bench Bench `skip:"true" mapstructure:", squash'`
}

type Agent struct {
Expand Down Expand Up @@ -187,6 +186,3 @@ type Exec struct {

Tags map[string]string `name:"tag" def:"" desc:"tag in key=value form. The flag may be specified multiple times" mapstructure:"tags"`
}

type Bench struct {
}

0 comments on commit a0659df

Please sign in to comment.