chore(db): typo and respect go guidelines

Signed-off-by: Klagarge <remi@heredero.ch>
This commit is contained in:
2026-04-30 13:26:31 +02:00
parent 567e9162e2
commit 1fb294f495
4 changed files with 12 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
# Deployement # Deployment
1. Create the Influx token offline: 1. Create the Influx token offline:

View File

@@ -9,13 +9,10 @@ import (
"github.com/InfluxCommunity/influxdb3-go/v2/influxdb3/batching" "github.com/InfluxCommunity/influxdb3-go/v2/influxdb3/batching"
) )
// Number of points to batch before pushing to InfluxDB const BatchSize = 50 // Number of points to batch before pushing to InfluxDB
const BATCH_SIZE = 50 const BatchCapacity = 50 // Capacity maximum of the buffer
// Capacity maximum of the buffer // Gateway provides the abstraction of all gateways to send data points
const BATCH_CAPACITY = 50
// Gateway provides the abstraction of all gateway to send datapoints
type Gateway interface { type Gateway interface {
AddDatapoint(dp datapoint.DataPointInfo) error AddDatapoint(dp datapoint.DataPointInfo) error
Close() error Close() error
@@ -46,8 +43,8 @@ func NewInfluxGateway(url string, token string, database string) (*InfluxGateway
return &InfluxGateway{ return &InfluxGateway{
client: client, client: client,
batcher: batching.NewBatcher( batcher: batching.NewBatcher(
batching.WithSize(BATCH_SIZE), batching.WithSize(BatchSize),
batching.WithInitialCapacity(BATCH_CAPACITY), batching.WithInitialCapacity(BatchCapacity),
), ),
}, },
nil nil
@@ -55,7 +52,7 @@ func NewInfluxGateway(url string, token string, database string) (*InfluxGateway
// AddDatapoint is used to add a datapoint in the batcher. It uses the // AddDatapoint is used to add a datapoint in the batcher. It uses the
// DataPointInfo interface for abstracting the generic type of the DataPoint. // DataPointInfo interface for abstracting the generic type of the DataPoint.
// It pushs the batch of point when the number of point >= batch size. // It pushes the batch of point when the number of points >= batch size.
func (g *InfluxGateway) AddDatapoint(dp datapoint.DataPointInfo) error { func (g *InfluxGateway) AddDatapoint(dp datapoint.DataPointInfo) error {
g.batcher.Add( g.batcher.Add(

View File

@@ -34,7 +34,7 @@ type MqttGateway struct {
Client mqtt.Client Client mqtt.Client
} }
// mqttPayload is the JSON structure published to the broker in specific topic. // mqttPayload is the JSON structure published to the broker in a specific topic.
// It contains the values and the timestamp of the data. // It contains the values and the timestamp of the data.
type mqttPayload map[string]any type mqttPayload map[string]any
@@ -109,7 +109,7 @@ func NewMqttGateway(p MqttParams) (*MqttGateway, error) {
}, nil }, nil
} }
// SendData is used to send a data in the MQTT gateway. // SendData is used to send data in the MQTT gateway.
// It uses the DataPointInfo interface for abstracting the generic type of the DataPoint // It uses the DataPointInfo interface for abstracting the generic type of the DataPoint
func (g *MqttGateway) SendData(msg data.MessageInfo) error { func (g *MqttGateway) SendData(msg data.MessageInfo) error {
topic := msg.Topic() topic := msg.Topic()

View File

@@ -20,7 +20,7 @@ type Measurement[T any] struct {
} }
// A DataPoint represents values associated with a measurement, along with tags, // A DataPoint represents values associated with a measurement, along with tags,
// values and a timestamp. It contains a pointer to its parent Measurement // values, and a timestamp. It contains a pointer to its parent Measurement
type DataPoint[T any] struct { type DataPoint[T any] struct {
measurement *Measurement[T] measurement *Measurement[T]
tags map[string]string tags map[string]string
@@ -57,8 +57,8 @@ func (dp *DataPoint[T]) GetValues() map[string]T {
return dp.values return dp.values
} }
// GetValuesAny returns the DataPoint value with type any. // GetValuesAsAny returns the DataPoint value with type any.
// (usefull for adding the DataPoint for batching) // (useful for adding the DataPoint for batching)
func (dp *DataPoint[T]) GetValuesAsAny() map[string]any { func (dp *DataPoint[T]) GetValuesAsAny() map[string]any {
anyValues := make(map[string]any) anyValues := make(map[string]any)