-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh: add simple boilerplate for AI challenge
- Loading branch information
1 parent
1041561
commit 463b43c
Showing
7 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
version: '3.8' | ||
|
||
services: | ||
postgres: | ||
image: postgres:latest | ||
environment: | ||
POSTGRES_DB: yourdbname | ||
POSTGRES_USER: youruser | ||
POSTGRES_PASSWORD: yourpassword | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- postgres-data:/var/lib/postgresql/data | ||
|
||
qdrant: | ||
image: qdrant/qdrant | ||
ports: | ||
- "6333:6333" | ||
volumes: | ||
- qdrant-data:/qdrant/storage | ||
|
||
volumes: | ||
postgres-data: | ||
qdrant-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
POSTGRES_HOST=localhost | ||
POSTGRES_PORT=5432 | ||
POSTGRES_USER=youruser | ||
POSTGRES_PASSWORD=yourpassword | ||
POSTGRES_DB=yourdbname | ||
QDRANT_HOST=localhost | ||
QDRANT_PORT=6333 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module goapp | ||
|
||
go 1.22.3 | ||
|
||
require ( | ||
github.com/joho/godotenv v1.5.1 | ||
github.com/lib/pq v1.10.9 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= | ||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= | ||
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= | ||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package main | ||
|
||
import ( | ||
"database/sql" | ||
"fmt" | ||
"log" | ||
"net/http" | ||
"os" | ||
|
||
"github.com/joho/godotenv" | ||
_ "github.com/lib/pq" | ||
) | ||
|
||
func main() { | ||
// Load .env file | ||
err := godotenv.Load() | ||
if err != nil { | ||
log.Fatalf("Error loading .env file: %v", err) | ||
} | ||
|
||
// Connect to PostgreSQL | ||
pgConnStr := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable", | ||
os.Getenv("POSTGRES_HOST"), os.Getenv("POSTGRES_PORT"), os.Getenv("POSTGRES_USER"), os.Getenv("POSTGRES_PASSWORD"), os.Getenv("POSTGRES_DB")) | ||
db, err := sql.Open("postgres", pgConnStr) | ||
if err != nil { | ||
log.Fatalf("Error connecting to PostgreSQL: %v", err) | ||
} | ||
defer db.Close() | ||
|
||
// Connect to Qdrant | ||
qdrantURL := fmt.Sprintf("http://%s:%s", os.Getenv("QDRANT_HOST"), os.Getenv("QDRANT_PORT")) | ||
resp, err := http.Get(qdrantURL + "/v1/collections") | ||
if err != nil { | ||
log.Fatalf("Error connecting to Qdrant: %v", err) | ||
} | ||
defer resp.Body.Close() | ||
|
||
// Simple HTTP server | ||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
fmt.Fprintf(w, "Connected to PostgreSQL and Qdrant successfully!") | ||
}) | ||
log.Fatal(http.ListenAndServe(":8080", nil)) | ||
} |
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters