-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add v3 native write endpoint support #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -102,6 +102,9 @@ type Simulator struct { | |||||||||||||
| TargetMaxLatency time.Duration | ||||||||||||||
| Gzip bool | ||||||||||||||
| Precision string | ||||||||||||||
| V3 bool // enables the v3 native write endpoint which has additional semantics; db and precision are required | ||||||||||||||
| V3NoSync bool // v3 supports a "no-sync" option, when true will ACK write as soon as possible without waiting for wal durability | ||||||||||||||
| V3AcceptPartial bool // allow partial write success when some lines in a batch fail to write | ||||||||||||||
|
|
||||||||||||||
| Database string | ||||||||||||||
| RetentionPolicy string // Write to a specific retention policy | ||||||||||||||
|
|
@@ -183,6 +186,10 @@ func (s *Simulator) Validate() error { | |||||||||||||
| el = append(el, fmt.Errorf("invalid precision: %s", s.Precision)) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if !s.V3 && (s.V3NoSync || s.V3AcceptPartial) { | ||||||||||||||
| fmt.Fprintf(s.Stdout, "Warning: InfluxDB 3 flag(s) set to true, but V3 write endpoint not being used; flags will have no effect.\n") | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if len(el) > 0 { | ||||||||||||||
| return el | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -218,11 +225,14 @@ func (s *Simulator) Run(ctx context.Context) error { | |||||||||||||
| fmt.Fprintf(s.Stdout, "Retention Policy: %s\n", s.RetentionPolicy) | ||||||||||||||
| fmt.Fprintf(s.Stdout, "Write Consistency: %s\n", s.Consistency) | ||||||||||||||
| fmt.Fprintf(s.Stdout, "Writing into InfluxDB 2.0: %t\n", s.V2) | ||||||||||||||
| fmt.Fprintf(s.Stdout, "InfluxDB 2.0 Authorization Token: %s\n", s.Token) | ||||||||||||||
| fmt.Fprintf(s.Stdout, "InfluxDB 2 or 3 Authorization Token: %s\n", s.Token) | ||||||||||||||
|
||||||||||||||
| fmt.Fprintf(s.Stdout, "InfluxDB 2 or 3 Authorization Token: %s\n", s.Token) | |
| if s.Token == "" { | |
| fmt.Fprintf(s.Stdout, "InfluxDB 2 or 3 Authorization Token: (not set)\n") | |
| } else { | |
| fmt.Fprintf(s.Stdout, "InfluxDB 2 or 3 Authorization Token: (set, length %d)\n", len(s.Token)) | |
| } |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the missing-token case, this returns err from Validate(), which is nil here, so Run() exits successfully (exit code 0) even though an error was printed. Return a real error (and consider writing the message to Stderr) so callers can detect the failure.
| fmt.Println("ERROR: Need to provide a token in order to write into InfluxDB 2 or 3") | |
| return err | |
| fmt.Fprintln(os.Stderr, "ERROR: Need to provide a token in order to write into InfluxDB 2 or 3") | |
| return errors.New("need to provide a token in order to write into InfluxDB 2 or 3") |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The v3 write URL is built via string formatting without URL-escaping query parameter values. If Database/Precision contain characters that need escaping, the request can be malformed. Use net/url to build the URL + query (and reuse it for the non-v3 branches for consistency).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate()doesn’t currently enforce any constraints around the new v3 flags beyond a warning. Consider making these cases hard errors: (1)-v2and-v3both set (ambiguous behavior), and (2)-v3set with an emptyDatabase(required for/api/v3/write_lp). This will fail fast instead of producing confusing runtime errors.