Skip to content
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
7eab5de
[interfaces] InfluxDBProvider, InfluxDB interface added with all the …
akhilsharmaa Jul 5, 2025
495cca8
[healthcheck] function implemented for the healthcheck of influxdb cl…
akhilsharmaa Jul 7, 2025
d12d464
[ListBuckets] function implemented, user can get the all the bucket b…
akhilsharmaa Jul 11, 2025
359e1d3
[implementation] CreateOrganization, DeleteOrganization, DeleteOrgani…
akhilsharmaa Jul 13, 2025
1b287d3
useMetrics, useLogger, useTracer implemented.
akhilsharmaa Jul 15, 2025
b926361
[docs] documentation for the influxdb and example for using this.
akhilsharmaa Jul 15, 2025
725354d
[test+comments] Added the tests and proper comments, current coverage…
akhilsharmaa Jul 22, 2025
f5c1422
[refactor] using predefined errors, for consistent errors.
akhilsharmaa Jul 22, 2025
5069344
[tests] Unit test for Creating and Deleting Organization.
akhilsharmaa Jul 24, 2025
e4d573f
[tests] Unit test for Buckets operation written, achieving 72% coverage.
akhilsharmaa Jul 24, 2025
080eb8f
[write, query] implemented functions of influxdb to insert data & per…
akhilsharmaa Jul 27, 2025
9cf1c3d
[test] added test for the write and query on influxdb.
akhilsharmaa Jul 27, 2025
5896876
[linting] fixed various linting errors
akhilsharmaa Jul 29, 2025
b544346
[linting] fixed some linting errors
akhilsharmaa Jul 29, 2025
e2b7d69
[fixed-linting] all linting errors fixed.
akhilsharmaa Jul 29, 2025
aabc2b5
[fixed-linting] all linting errors fixed.
akhilsharmaa Jul 29, 2025
2090fc1
[fixed-linting] container linting errors fixed.
akhilsharmaa Jul 29, 2025
68b2ab8
Merge branch 'development' into influxdbConnector
Umang01-hash Jul 31, 2025
06d9a6f
[fixed-linting] some linting issues fixed.
akhilsharmaa Jul 31, 2025
e2e4a8f
Merge remote-tracking branch 'origin/influxdbConnector' into influxdb…
akhilsharmaa Jul 31, 2025
ad1116c
[mocking] mocking metrics + logger
akhilsharmaa Aug 4, 2025
9befb08
[removed] docker-compose.yml (was just experiment)
akhilsharmaa Aug 4, 2025
1588bf7
[fix] metric + tracer added.
akhilsharmaa Aug 5, 2025
2f0e55f
[mock] influx client for mock tests.
akhilsharmaa Aug 6, 2025
14b3048
[mock] health Success + Fail (both completed) Ping test completed.
akhilsharmaa Aug 7, 2025
6b549db
[tests] createOrganization tests added, checking conditions of empty,…
akhilsharmaa Aug 7, 2025
91d4b2f
[tests] Test_DeleteOrganization tests added, checking conditions of e…
akhilsharmaa Aug 7, 2025
de341d3
Merge branch 'development' into influxdbConnector
coolwednesday Aug 7, 2025
cb68b3d
[tests] Test_ListOrganization tests added for checking conditions of …
akhilsharmaa Aug 7, 2025
f2002ac
Merge branch 'listorganizationTest' into influxdbConnector
akhilsharmaa Aug 7, 2025
f8bc4c4
[tests] Test_CreateBucket tests added. Currently coverage - 47% .
akhilsharmaa Aug 7, 2025
dcafa99
[tests] Test_DeleteBucket tests added. Currently coverage - 48% .
akhilsharmaa Aug 7, 2025
c2e7036
[tests] Test_ListBucket tests added. coverage - 54.3% .
akhilsharmaa Aug 7, 2025
be1f3f5
[file delete] old test file deleted, which was not mocking the influx…
akhilsharmaa Aug 7, 2025
70933b7
[linting] fixed linting issues.
akhilsharmaa Aug 7, 2025
8859e29
[tests] Test_Query tests added. coverage - 57.1% .
akhilsharmaa Aug 8, 2025
cb85903
[docs] added index in navigation.
akhilsharmaa Aug 10, 2025
e797747
[logger] fixed , using app logger instead of fmt.
akhilsharmaa Aug 11, 2025
b1e3086
[logger] fixed , using app logger instead of fmt.
akhilsharmaa Aug 11, 2025
f2b8ab8
Merge branch 'development' into influxdbConnector
Umang01-hash Aug 12, 2025
5262ff0
[minimized] InfluxClient inteface got rid of extra function which are…
akhilsharmaa Aug 12, 2025
e6038ed
[refactor] coverage completed, getting 41% coverage.
akhilsharmaa Aug 14, 2025
3a21868
[tests] added tests for the Buckets, 50% coverrage.
akhilsharmaa Aug 14, 2025
0936b95
Merge branch 'development' into fixResolve
Aug 20, 2025
3b436b6
Merge branch 'fixResolve'
Aug 20, 2025
ddd334c
Merge branch 'development' into influxdbConnector
Umang01-hash Aug 25, 2025
1fd9cae
[revert] container mocks (not relevent to my PR)
akhilsharmaa Aug 27, 2025
b9b8813
Merge branch 'development' into influxdbConnector
akhilsharmaa Aug 27, 2025
9437e09
change path of the interface mock code to same folder.
akhilsharmaa Aug 27, 2025
86f1e07
Merge remote-tracking branch 'refs/remotes/origin/influxdbConnector'
akhilsharmaa Aug 27, 2025
c9b8702
[Fixed linting]
akhilsharmaa Aug 27, 2025
d6e1192
Merge branch 'development' into influxdbConnector
Umang01-hash Aug 29, 2025
3a5b76b
Merge branch 'development' into influxdbConnector
akhilsharmaa Aug 29, 2025
b70ba41
Merge branch 'development' into influxdbConnector
Umang01-hash Sep 1, 2025
5b7d5b3
Merge branch 'development' into influxdbConnector
Umang01-hash Sep 1, 2025
58dab37
Merge branch 'development' into influxdbConnector
Umang01-hash Sep 2, 2025
3802a72
[typo] replace influx2 -> influx
akhilsharmaa Sep 3, 2025
9f3167e
Merge remote-tracking branch 'refs/remotes/origin/influxdbConnector'
akhilsharmaa Sep 3, 2025
f842ee8
[revert] changes reverted beacause of the side effect of golint --fix
akhilsharmaa Sep 3, 2025
656f889
[revert] golint --fix side effects.
akhilsharmaa Sep 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
version: "3.8"

services:
mongodb:
image: mongodb/mongodb-community-server:latest
container_name: mongodb
ports:
- "27017:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: user
MONGO_INITDB_ROOT_PASSWORD: password

ftp-server:
image: delfer/alpine-ftp-server
ports:
- "21:21"
- "21000-21010:21000-21010"
environment:
USERS: "user|password"

opentsdb:
image: petergrace/opentsdb-docker:latest
container_name: gofr-opentsdb
ports:
- "4242:4242"

mysql:
image: mysql:8.0.30
container_name: gofr-mysql
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: test
ports:
- "2001:3306"

redis:
image: redis:7.0.5
container_name: gofr-redis
ports:
- "2002:6379"

solr:
image: solr
container_name: gofr-solr
command: solr -DzkRun
ports:
- "2020:8983"

zipkin:
image: openzipkin/zipkin:2
container_name: gofr-zipkin
ports:
- "2005:9411"

localstack:
image: localstack/localstack
ports:
- "4566:4566"
- "4510-4559:4510-4559"
tty: true
stdin_open: true
restart: unless-stopped

cassandra:
image: cassandra:latest
container_name: cassandra-node
ports:
- "9042:9042"
volumes:
- cassandra_data:/var/lib/cassandra

postgres:
image: postgres:15.1
container_name: gofr-pgsql
environment:
POSTGRES_DB: customers
POSTGRES_PASSWORD: root123
ports:
- "2006:5432"

mssql:
image: mcr.microsoft.com/azure-sql-edge
container_name: gofr-mssql
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: "reallyStrongPwd123"
ports:
- "2007:1433"

kafka:
image: bitnami/kafka:3.4
container_name: kafka-1
ports:
- "9092:9092"
environment:
KAFKA_ENABLE_KRAFT: "yes"
KAFKA_CFG_PROCESS_ROLES: "broker,controller"
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: "CONTROLLER"
KAFKA_CFG_LISTENERS: "PLAINTEXT://:9092,CONTROLLER://:9093"
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: "CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT"
KAFKA_CFG_ADVERTISED_LISTENERS: "PLAINTEXT://127.0.0.1:9092"
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "true"
KAFKA_BROKER_ID: "1"
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: "[email protected]:9093"
ALLOW_PLAINTEXT_LISTENER: "yes"
KAFKA_CFG_NODE_ID: "1"
volumes:
- kafka_data:/bitnami

scylla:
image: scylladb/scylla
container_name: scylla
ports:
- "2025:9042"

nats:
image: nats:latest
container_name: nats-server
command: -js
ports:
- "4222:4222"
- "8222:8222"

surrealdb:
image: surrealdb/surrealdb:latest
container_name: surrealdb
command: start --bind 0.0.0.0:8000
ports:
- "8000:8000"

arangodb:
image: arangodb:latest
container_name: arangodb
ports:
- "8529:8529"
environment:
ARANGO_ROOT_PASSWORD: rootpassword
pull_policy: always

volumes:
cassandra_data:
kafka_data:
129 changes: 129 additions & 0 deletions docs/datasources/influxdb/page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# InfluxDB
GoFr supports injecting InfluxDB using an interface that defines the necessary methods to interact with InfluxDB v2+.
Any driver that implements this interface can be injected via the `app.AddInfluxDB()` method.

---

## Interface

```go
// InfluxDB defines the methods for interacting with an InfluxDB database.
type InfluxDB interface {
Connect()
CreateOrganization(ctx context.Context, orgName string) (string, error)
DeleteOrganization(ctx context.Context, orgID string) error
ListOrganization(ctx context.Context) (map[string]string, error)

CreateBucket(ctx context.Context, orgID string, bucketName string, retentionPeriod time.Duration) (string, error)
DeleteBucket(ctx context.Context, orgID, bucketID string) error
ListBuckets(ctx context.Context, org string) (map[string]string, error)

Ping(ctx context.Context) (bool, error)
HealthCheck(ctx context.Context) (any, error)

Query(ctx context.Context, org string, fluxQuery string) ([]map[string]any, error)
WritePoints(ctx context.Context, bucket string, org string, points []container.InfluxPoint) error)

UseLogger(logger any)
UseMetrics(metrics any)
UseTracer(tracer any)
Comment on lines +27 to +29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not exposed to user. Refer to mongoDB datasource addition for more info.

}
```

This structure supports all essential InfluxDB operations including organization/bucket management, health checks, and metrics ingestion.

Import the gofr's external driver for influxdb:

```bash
go get gofr.dev/pkg/gofr/datasource/influxdb@latest
```

## Example
```go
package main

import (
"context"
"fmt"
"time"

"gofr.dev/pkg/gofr"
"gofr.dev/pkg/gofr/datasource/influxdb"
)

func main() {

// Create a new GoFr application
app := gofr.New()

// Initialize InfluxDB client
client := influxdb.New(influxdb.Config{
Url: "http://localhost:8086",
Username: "admin",
Password: "admin1234",
Token: "<your-token>",
})

// Add InfluxDB to application context
app.AddInfluxDB(client)

// Sample route
app.GET("/greet", func(ctx *gofr.Context) (any, error) {
return "Hello World!", nil
})

// Ping InfluxDB
ok, err := client.Ping(context.Background())
if err != nil {
fmt.Println("Ping failed:", err)
return
}
fmt.Println("InfluxDB connected:", ok)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use app.logger()


// Create organization
orgID, err := client.CreateOrganization(context.Background(), "demo-org")
if err != nil {
fmt.Println("CreateOrganization error:", err)
return
}

// List organizations
orgs, _ := client.ListOrganization(context.Background())
fmt.Println("Organizations:")
for id, name := range orgs {
fmt.Printf("- %s: %s\n", id, name)
}

// Create bucket
bucketID, err := client.CreateBucket(context.Background(), orgID, "demo-bucket", time.Hour)
if err != nil {
fmt.Println("CreateBucket error:", err)
return
}

// List buckets for organization
buckets, err := client.ListBuckets(context.Background(), "demo-org")
if err != nil {
fmt.Println("ListBuckets error:", err)
return
}
fmt.Println("Buckets:", buckets)

// Delete bucket
if err := client.DeleteBucket(context.Background(), orgID, bucketID); err != nil {
fmt.Println("DeleteBucket error:", err)
return
}
fmt.Println("Bucket deleted successfully")

// Delete organization
if err := client.DeleteOrganization(context.Background(), orgID); err != nil {
fmt.Println("DeleteOrganization error:", err)
return
}
fmt.Println("Organization deleted successfully")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write a setup function .... pseudo and then make REST endpoints for adding, retrieving data.

// Start the server
app.Run()
}
```
5 changes: 2 additions & 3 deletions go.work
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
go 1.24.0

toolchain go1.24.0
go 1.24.2

use (
.
Expand All @@ -22,4 +20,5 @@ use (
./pkg/gofr/datasource/scylladb
./pkg/gofr/datasource/solr
./pkg/gofr/datasource/surrealdb
pkg/gofr/datasource/influxdb
)
Loading
Loading