From 1fb294f495ea1b117512b1311d128ba7ab15cad8 Mon Sep 17 00:00:00 2001 From: Klagarge Date: Thu, 30 Apr 2026 13:26:31 +0200 Subject: [PATCH] chore(db): typo and respect go guidelines Signed-off-by: Klagarge --- db/README.md | 2 +- db/src/influx/influx_gateway.go | 15 ++++++--------- db/src/mqtt/mqtt_gateway.go | 4 ++-- db/src/point/datapoint.go | 6 +++--- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/db/README.md b/db/README.md index 5e95ebd..941ddd9 100644 --- a/db/README.md +++ b/db/README.md @@ -1,4 +1,4 @@ -# Deployement +# Deployment 1. Create the Influx token offline: diff --git a/db/src/influx/influx_gateway.go b/db/src/influx/influx_gateway.go index c6440cd..b2d288e 100644 --- a/db/src/influx/influx_gateway.go +++ b/db/src/influx/influx_gateway.go @@ -9,13 +9,10 @@ import ( "github.com/InfluxCommunity/influxdb3-go/v2/influxdb3/batching" ) -// Number of points to batch before pushing to InfluxDB -const BATCH_SIZE = 50 +const BatchSize = 50 // Number of points to batch before pushing to InfluxDB +const BatchCapacity = 50 // Capacity maximum of the buffer -// Capacity maximum of the buffer -const BATCH_CAPACITY = 50 - -// Gateway provides the abstraction of all gateway to send datapoints +// Gateway provides the abstraction of all gateways to send data points type Gateway interface { AddDatapoint(dp datapoint.DataPointInfo) error Close() error @@ -46,8 +43,8 @@ func NewInfluxGateway(url string, token string, database string) (*InfluxGateway return &InfluxGateway{ client: client, batcher: batching.NewBatcher( - batching.WithSize(BATCH_SIZE), - batching.WithInitialCapacity(BATCH_CAPACITY), + batching.WithSize(BatchSize), + batching.WithInitialCapacity(BatchCapacity), ), }, 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 // 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 { g.batcher.Add( diff --git a/db/src/mqtt/mqtt_gateway.go b/db/src/mqtt/mqtt_gateway.go index fe497d9..994c5c7 100644 --- a/db/src/mqtt/mqtt_gateway.go +++ b/db/src/mqtt/mqtt_gateway.go @@ -34,7 +34,7 @@ type MqttGateway struct { 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. type mqttPayload map[string]any @@ -109,7 +109,7 @@ func NewMqttGateway(p MqttParams) (*MqttGateway, error) { }, 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 func (g *MqttGateway) SendData(msg data.MessageInfo) error { topic := msg.Topic() diff --git a/db/src/point/datapoint.go b/db/src/point/datapoint.go index bebd6a8..4817f36 100644 --- a/db/src/point/datapoint.go +++ b/db/src/point/datapoint.go @@ -20,7 +20,7 @@ type Measurement[T any] struct { } // 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 { measurement *Measurement[T] tags map[string]string @@ -57,8 +57,8 @@ func (dp *DataPoint[T]) GetValues() map[string]T { return dp.values } -// GetValuesAny returns the DataPoint value with type any. -// (usefull for adding the DataPoint for batching) +// GetValuesAsAny returns the DataPoint value with type any. +// (useful for adding the DataPoint for batching) func (dp *DataPoint[T]) GetValuesAsAny() map[string]any { anyValues := make(map[string]any)