Skip to content

Commit

Permalink
feat: Set no rp if defaulted
Browse files Browse the repository at this point in the history
  • Loading branch information
devanbenz committed Jan 3, 2025
1 parent e78b7d1 commit 0853f0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/inch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (m *Main) ParseFlags(args []string) error {
fs.BoolVar(&m.inch.RandomizeFields, "randomize-fields", false, "Randomize field values")
fs.BoolVar(&m.inch.OneFieldPerLine, "one-field-per-line", false, "One line of line protocol per field instead of one line per point")
fs.IntVar(&m.inch.BatchSize, "b", 5000, "Batch size")
fs.StringVar(&m.inch.RetentionPolicy, "rp", "autogen", "Retention policy to write to")
fs.StringVar(&m.inch.RetentionPolicy, "rp", "", "Retention policy to write to")
fs.StringVar(&m.inch.Database, "db", "stress", "Database to write to")
fs.StringVar(&m.inch.ShardDuration, "shard-duration", "7d", "Set shard duration (default 7d)")
fs.StringVar(&m.inch.StartTime, "start-time", "", "Set start time (default now)")
Expand Down
9 changes: 8 additions & 1 deletion inch.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,14 @@ var defaultSetupFn = func(s *Simulator) error {
// defaultWriteBatch is the default implementation of the WriteBatch function.
// It's the caller's responsibility to close the response body.
var defaultWriteBatch = func(s *Simulator, buf []byte) (statusCode int, body io.ReadCloser, err error) {
req, err := http.NewRequest("POST", fmt.Sprintf("%s/write?db=%s&rp=%s&precision=%s&consistency=%s", s.Host, s.Database, s.RetentionPolicy, s.Precision, s.Consistency), bytes.NewReader(buf))
var url string
if s.RetentionPolicy == "" {
url = fmt.Sprintf("%s/write?db=%s&precision=%s&consistency=%s", s.Host, s.Database, s.Precision, s.Consistency)
} else {
url = fmt.Sprintf("%s/write?db=%s&rp=%s&precision=%s&consistency=%s", s.Host, s.Database, s.RetentionPolicy, s.Precision, s.Consistency)
}

req, err := http.NewRequest("POST", url, bytes.NewReader(buf))
if err != nil {
return 0, nil, err
}
Expand Down

0 comments on commit 0853f0a

Please sign in to comment.