Skip to content

Commit

Permalink
feat(sim): added demo schema random simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
bvdeenen committed Aug 11, 2021
1 parent 93e716b commit 3311aec
Show file tree
Hide file tree
Showing 15 changed files with 877 additions and 48 deletions.
2 changes: 1 addition & 1 deletion cmd/strm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func setupVerbs() {
RootCmd.AddCommand(cmd.DeleteCmd)
RootCmd.AddCommand(cmd.ListCmd)
RootCmd.AddCommand(cmd.CompletionCmd)
RootCmd.AddCommand(cmd.SimCmd)
RootCmd.AddCommand(cmd.SimCmd())
RootCmd.AddCommand(cmd.EgressCmd)
RootCmd.AddCommand(cmd.AuthCmd)
RootCmd.AddCommand(cmd.VersionCmd)
Expand Down
25 changes: 19 additions & 6 deletions pkg/cmd/sim.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,28 @@ package cmd

import (
"github.com/spf13/cobra"
"streammachine.io/strm/pkg/sim"
"streammachine.io/strm/pkg/sim/randomsim"
)

// SimCmd represents the create command
var SimCmd = &cobra.Command{
Use: "sim",
Short: "Simulate events",
func SimCmd() (cmd *cobra.Command) {
// SimCmd represents the create command
simCmd := &cobra.Command{
Use: "sim",
Short: "Simulate events",
}

flags := simCmd.PersistentFlags()
flags.String(sim.SchemaFlag, "streammachine/demo/1.0.2", "what schema to simulate")
_ = simCmd.RegisterFlagCompletionFunc(sim.SchemaFlag, schemaCompletion)
simCmd.AddCommand(randomsim.RunCmd())
return simCmd
}

func init() {
SimCmd.AddCommand(randomsim.RunCmd())
func schemaCompletion(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
keys := make([]string, 0, len(randomsim.EventGenerators))
for key := range randomsim.EventGenerators {
keys = append(keys, key)
}
return keys, cobra.ShellCompDirectiveDefault
}
54 changes: 54 additions & 0 deletions pkg/demoschema/array_int.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

168 changes: 168 additions & 0 deletions pkg/demoschema/demo_event.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3311aec

Please sign in to comment.