InfluxCommunity / influxdb3-go

The go package that provides a simple and convenient way to interact with InfluxDB 3.
https://pkg.go.dev/github.com/InfluxCommunity/influxdb3-go
MIT License
21 stars 11 forks source link

feat: type-safe conversion for line-protocol Addfield #43 #42

Closed arukiidou closed 8 months ago

arukiidou commented 9 months ago

Proposed Changes

func (m *Point) AddFieldFromValue(k string, v lineprotocol.Value) *Point {}
func NewValueFromInt[I Integer](v I) lineprotocol.Value {}

Usage

func example() {
    p := NewPoint("measurement", map[string]string{}, map[string]interface{}{"measurement": "air"}, time.Now())
        // unsupported type.
    p.AddFieldFromValue("βœ… Compile error.", cmplx.Inf())
        // supported type.
    p.AddFieldFromValue("βœ… This is safe.", NewValueFromInt(255))
}

Checklist

bednar commented 9 months ago

@arukiidou, thank you for using our client and for your PR. We're excited to review it once it's ready.

arukiidou commented 9 months ago

ready for review. πŸ‘ rebased behind of v0.3.0

arukiidou commented 9 months ago

fixed,sorryπŸ™

bednar commented 9 months ago

I have a question regarding the use of lineprotocol.Value. Is its usage necessary? What do you think about adding something like AddStringField(k string, v string) to Point?

func (m *Point) AddStringField(k string, v string) *Point {
    m.AddField(k, v)
    return m
}
arukiidou commented 9 months ago

I have a question regarding the use of lineprotocol.Value. Is its usage necessary? What do you think about adding something like AddStringField(k string, v string) to Point?

func (m *Point) AddStringField(k string, v string) *Point {
  m.AddField(k, v)
  return m
}
bednar commented 9 months ago

We aim to synchronize the API across our v3 clients β€” js, go, java, and c#. We've already updated the API in both the c# and js clients. For more information, see:

JS Client PR #89 JS Client PR #89 File Diff C# Client PR #52 C# Client PR #52 File Diff

bednar commented 8 months ago

@arukiidou thanks again for your PR. Can you please align your code with upcoming changes for structured query - https://github.com/InfluxCommunity/influxdb3-go/pull/45?

arukiidou commented 8 months ago

@arukiidou thanks again for your PR. Can you please align your code with upcoming changes for structured query - #45?

Yes, I will do so. It may take some time.

arukiidou commented 8 months ago

@bednar