Skip to content

Commit

Permalink
Merge pull request #424 from streamdal/dselans/demo-client-updates
Browse files Browse the repository at this point in the history
demo client updates for async and sampling
  • Loading branch information
dselans committed May 8, 2024
2 parents 7de6bd8 + 534737b commit 47495f5
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 17 deletions.
49 changes: 49 additions & 0 deletions apps/server/test-utils/demo-client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ run/all:
run1: description = Run signup-service
run1:
go run *.go -d \
--display-exec-time \
--message-rate 1 \
--service-name "signup-service" \
--operation-type 2 \
Expand All @@ -46,6 +47,7 @@ run2: description = Run signup-service
run2:
go run *.go -d \
--quiet \
--display-exec-time \
--message-rate 10,20 \
--service-name "signup-service" \
--operation-type 2 \
Expand Down Expand Up @@ -119,6 +121,53 @@ run7:
--data-source-type file \
--data-source-file ./assets/pii-key-value.json

.PHONY: run/async
run/async: description = Run signup-service-async service configured with async
run/async:
go run *.go -d \
--quiet \
--async \
--display-exec-time \
--message-rate 10,20 \
--service-name "signup-service-async" \
--operation-type 2 \
--operation-name "recorder" \
--component-name "kafka" \
--data-source-type file \
--data-source-file ./assets/sample.json

.PHONY: run/sampling
run/sampling: description = Run signup-service-async service configured with sampling rate of 1 message/sec
run/sampling:
go run *.go -d \
--quiet \
--sampling-rate 1 \
--display-exec-time \
--message-rate 10,100 \
--service-name "signup-service-sampling" \
--operation-type 2 \
--operation-name "verifier" \
--component-name "mysql" \
--data-source-type file \
--data-source-file ./assets/sample.json

.PHONY: run/async-sampling
run/async-sampling: description = Run signup-service-async service configured with async and sampling
run/async-sampling:
go run *.go -d \
--quiet \
--async \
--sampling-rate 1 \
--display-exec-time \
--message-rate 10,100 \
--service-name "signup-service-async-sampling" \
--operation-type 2 \
--operation-name "worker" \
--component-name "postgresql" \
--data-source-type file \
--data-source-file ./assets/sample.json


### Build

.PHONY: build
Expand Down
2 changes: 2 additions & 0 deletions apps/server/test-utils/demo-client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type Config struct {
DataSourceType string `kong:"help='Type of data source this client will use', enum='none,file',default='none'"`
DataSourceFile *os.File `kong:"help='File that contains sample data - used only when DataSourceType=file'"`
DisplayExecTime bool `kong:"help='Display execution time for each message',default='false'"`
Async bool `kong:"help='Use async mode in go-sdk',default='false'"`
SamplingRate int `kong:"help='Enable sampling and sample rate in go-sdk',default='0'"`

ServerAddress string `kong:"help='Streamdal gRPC server address',default='localhost:8082',required"`
ServerToken string `kong:"help='Streamdal server token',default='1234',required"`
Expand Down
13 changes: 13 additions & 0 deletions apps/server/test-utils/demo-client/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ func (r *Demo) newClient() (*streamdal.Streamdal, error) {
cfg.Logger = r.log
}

if r.config.Async {
cfg.Mode = streamdal.ModeAsync
}

if r.config.SamplingRate > 0 {
cfg.SamplingEnabled = true
cfg.SamplingRate = r.config.SamplingRate
}

return streamdal.New(cfg)
}

Expand Down Expand Up @@ -365,6 +374,10 @@ func translateStatus(status protos.ExecStatus) string {
return color.YellowString("FALSE")
case protos.ExecStatus_EXEC_STATUS_ERROR:
return color.RedString("ERROR")
case protos.ExecStatus_EXEC_STATUS_ASYNC:
return color.HiBlueString("ASYNC")
case protos.ExecStatus_EXEC_STATUS_SAMPLING:
return color.HiBlueString("SAMPLING")
default:
return color.HiRedString("%s", status)
}
Expand Down
4 changes: 2 additions & 2 deletions apps/server/test-utils/demo-client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ require (
github.com/joho/godotenv v1.5.1
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
github.com/streamdal/streamdal/libs/protos v0.1.54
github.com/streamdal/streamdal/sdks/go v0.1.23
github.com/streamdal/streamdal/libs/protos v0.1.56
github.com/streamdal/streamdal/sdks/go v0.1.26
)

require (
Expand Down
4 changes: 4 additions & 0 deletions apps/server/test-utils/demo-client/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIK
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/streamdal/streamdal/libs/protos v0.1.54 h1:PX7u3m1wDwZtER77m7YvjRcBWvcKFiaRZ+yN7Xw+uJw=
github.com/streamdal/streamdal/libs/protos v0.1.54/go.mod h1:1rQ250ydoKeRoJftIV9qGrR28Iqdb9+7Jcnoxber/eQ=
github.com/streamdal/streamdal/libs/protos v0.1.56 h1:JyaUN939Sb+Jspx0g55fDy8VKUnyCOJ7yIsW2GMCos0=
github.com/streamdal/streamdal/libs/protos v0.1.56/go.mod h1:1rQ250ydoKeRoJftIV9qGrR28Iqdb9+7Jcnoxber/eQ=
github.com/streamdal/streamdal/sdks/go v0.1.23 h1:9jkqsnVnNhcTkuBuqeqQrts1fkUXOMXmOxH4oXh/424=
github.com/streamdal/streamdal/sdks/go v0.1.23/go.mod h1:c0BnT4skXHZ5hteMqZCadb4dZiQd5lPqNOn3GxQ21eo=
github.com/streamdal/streamdal/sdks/go v0.1.26 h1:OgCE2ZhoIoDhk0kzhVaxqnRyL7OFbpt3HUnRK4HDdVs=
github.com/streamdal/streamdal/sdks/go v0.1.26/go.mod h1:Qst/7V4lw3k9/55uClt2WS9OXyCl7l+/LqcWcdU14SI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
Expand Down
32 changes: 17 additions & 15 deletions apps/server/test-utils/demo-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,21 @@ func displayConfig(cfg *Config) {
}

logrus.Info("demo client settings:")
logrus.Infof(" server address: %s", cfg.ServerAddress)
logrus.Infof(" server token: %s", cfg.ServerToken)
logrus.Infof(" service name: %s", cfg.ServiceName)
logrus.Infof(" operation type: %d", cfg.OperationType)
logrus.Infof(" operation name: %s", cfg.OperationName)
logrus.Infof(" component name: %s", cfg.ComponentName)
logrus.Infof(" num instances: %d", cfg.NumInstances)
logrus.Infof(" reconnect random: %t", cfg.ReconnectRandom)
logrus.Infof(" reconnect interval: %d", cfg.ReconnectInterval)
logrus.Infof(" message rate: %v", cfg.MessageRate)
logrus.Infof(" data source type: %s", cfg.DataSourceType)
logrus.Infof(" data source file: %s", cfg.DataSourceFile.Name())
logrus.Infof(" debug: %t", cfg.Debug)
logrus.Infof(" quiet: %t", cfg.Quiet)
logrus.Infof(" inject logger: %t", cfg.InjectLogger)
logrus.Infof(" server address : %s", cfg.ServerAddress)
logrus.Infof(" server token : %s", cfg.ServerToken)
logrus.Infof(" service name : %s", cfg.ServiceName)
logrus.Infof(" operation type : %d", cfg.OperationType)
logrus.Infof(" operation name : %s", cfg.OperationName)
logrus.Infof(" component name : %s", cfg.ComponentName)
logrus.Infof(" async : %t", cfg.Async)
logrus.Infof(" sampling rate : %d", cfg.SamplingRate)
logrus.Infof(" num instances : %d", cfg.NumInstances)
logrus.Infof(" reconnect random : %t", cfg.ReconnectRandom)
logrus.Infof(" reconnect interval : %d", cfg.ReconnectInterval)
logrus.Infof(" message rate : %v", cfg.MessageRate)
logrus.Infof(" data source type : %s", cfg.DataSourceType)
logrus.Infof(" data source file : %s", cfg.DataSourceFile.Name())
logrus.Infof(" debug : %t", cfg.Debug)
logrus.Infof(" quiet : %t", cfg.Quiet)
logrus.Infof(" inject logger : %t", cfg.InjectLogger)
}

0 comments on commit 47495f5

Please sign in to comment.