diff --git a/opengemini/point.go b/opengemini/point.go new file mode 100644 index 0000000..cf8b49e --- /dev/null +++ b/opengemini/point.go @@ -0,0 +1,45 @@ +package opengemini + +import "time" + +type Point struct { + Measurement string + Precision string + Time time.Time + Tags map[string]string + Fields map[string]interface{} +} + +func (p *Point) AddTag(key string, value string) { + if p.Tags == nil { + p.Tags = make(map[string]string) + } + p.Tags[key] = value +} + +func (p *Point) AddField(key string, value interface{}) { + if p.Fields == nil { + p.Fields = make(map[string]interface{}) + } + p.Fields[key] = value +} + +func (p *Point) SetTime(t time.Time) { + p.Time = t +} + +func (p *Point) SetPrecision(precision string) { + p.Precision = precision +} + +func (p *Point) SetMeasurement(name string) { + p.Measurement = name +} + +type BatchPoints struct { + Points []*Point +} + +func (bp *BatchPoints) AddPoint(p *Point) { + bp.Points = append(bp.Points, p) +} diff --git a/opengemini/query_result.go b/opengemini/query_result.go new file mode 100644 index 0000000..0349243 --- /dev/null +++ b/opengemini/query_result.go @@ -0,0 +1,13 @@ +package opengemini + +// SeriesResult contains the results of a series query +type SeriesResult struct { + Series []Series `json:"series,omitempty"` + Error string `json:"error,omitempty"` +} + +// QueryResult is the top-level struct +type QueryResult struct { + Results []SeriesResult `json:"results,omitempty"` + Error string `json:"error,omitempty"` +} diff --git a/opengemini/series.go b/opengemini/series.go new file mode 100644 index 0000000..301b473 --- /dev/null +++ b/opengemini/series.go @@ -0,0 +1,9 @@ +package opengemini + +// Series defines the structure for series data +type Series struct { + Name string `json:"name,omitempty"` + Tags map[string]string `json:"tags,omitempty"` + Columns []string `json:"columns,omitempty"` + Values [][]interface{} `json:"values,omitempty"` +}