Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
76 changes: 76 additions & 0 deletions eigenix/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
.PHONY: build clean run test docker

# Build the Go service with C++ bindings
build:
@echo "Building Skye-Eigenix HNSW service with C++ bindings..."
CGO_ENABLED=1 go build -o eigenix ./cmd/eigenix

# Build and run the service (using go run to avoid security issues)
run:
@echo "Starting Skye-Eigenix HNSW service..."
CGO_ENABLED=1 go run ./cmd/eigenix

# Build and run from temp directory (alternative method)
run-safe: build-safe
@echo "Starting Skye-Eigenix service from temp directory..."
~/temp-build/eigenix

# Build in temp directory to avoid security software
build-safe:
@echo "Building Skye-Eigenix service in temp directory..."
@mkdir -p ~/temp-build
CGO_ENABLED=1 go build -o ~/temp-build/eigenix ./cmd/eigenix

# Run the example client (requires service to be running)
test-client:
@echo "Running example client..."
@echo "Note: Client example not yet implemented"

# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
rm -f eigenix vector-search-service hnsw-service
rm -rf indices
go clean

# Install dependencies
deps:
@echo "Installing Go dependencies..."
go mod tidy

# Build Docker image
docker:
@echo "Building Docker image..."
docker build -t hnsw-service .

# Run with Docker
docker-run:
@echo "Running with Docker..."
docker run -p 8080:8080 hnsw-service

# Development build with debug info
debug:
@echo "Building with debug info..."
CGO_ENABLED=1 go build -gcflags="all=-N -l" -o hnsw-service-debug .

# Check if C++ compiler is available
check-deps:
@echo "Checking dependencies..."
@which g++ > /dev/null || (echo "Error: g++ not found. Please install a C++ compiler." && exit 1)
@echo "βœ“ C++ compiler found"
@go version
@echo "βœ“ Go found"

# Help
help:
@echo "Available targets:"
@echo " build - Build the HNSW service"
@echo " run - Build and run the service"
@echo " test-client - Run the example client"
@echo " clean - Clean build artifacts"
@echo " deps - Install Go dependencies"
@echo " docker - Build Docker image"
@echo " docker-run - Run with Docker"
@echo " debug - Build with debug info"
@echo " check-deps - Check if dependencies are installed"
@echo " help - Show this help"
2 changes: 2 additions & 0 deletions eigenix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# skye-eigenix
IVF + HNSW Based Vector Database
8 changes: 8 additions & 0 deletions eigenix/cmd/eigenix/eigenix.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
APP_NAME=eigenix
APP_METRIC_SAMPLING_RATE=0.1

IS_HNSW_LIB_ENABLED=false
IS_QDRANT_ENABLED=true
QDRANT_CENTROID_FILE_PATH=""
QDRANT_HOST="localhost"
QDRANT_PORT="6334"
78 changes: 78 additions & 0 deletions eigenix/cmd/eigenix/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package main

import (
"os"
"os/signal"
"syscall"

"github.com/Meesho/go-core/config"
"github.com/Meesho/go-core/grpc"
"github.com/Meesho/go-core/metric"
pb "github.com/Meesho/skye-eigenix/internal/client"
"github.com/Meesho/skye-eigenix/internal/hnswlib"
"github.com/Meesho/skye-eigenix/internal/qdrant"
"github.com/Meesho/skye-eigenix/internal/serving"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
)

func main() {
// Load environment variables from .env file
config.InitEnv()
metric.Init()
os.Setenv("APP_NAME", "eigenix")
os.Setenv("APP_PORT", "8080")
initHNSWLib()
initQdrant()
grpc.Init()
// Register gRPC service
srv := serving.Init()
pb.RegisterEigenixServiceServer(grpc.Instance().GRPCServer, srv)

// Setup signal handling for graceful shutdown
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)

// Start gRPC server in a goroutine so it doesn't block
// Recover from any panics in this goroutine
go func() {
defer func() {
if r := recover(); r != nil {
log.Error().Interface("panic", r).Msg("gRPC server goroutine panicked")
}
}()
// Errors from Run() during shutdown are expected
_ = grpc.Instance().Run()
}()
log.Info().Msg("Server started successfully")

// Wait for termination signal
sig := <-sigChan
log.Info().Msgf("Received signal: %v. Shutting down gracefully...", sig)
log.Info().Msg("Initiating shutdown...")
}

func initHNSWLib() {
log.Info().Msg("Initializing HNSW library...")
db := hnswlib.Init()

// Load existing indices on startup
log.Info().Msg("Loading existing indices...")
db.LoadAllIndices()

// Ensure indices are saved on exit, even if there's a panic
defer func() {
if r := recover(); r != nil {
log.Error().Interface("panic", r).Msg("Recovered from panic during shutdown")
}
log.Info().Msg("Saving all indices before exit...")
db.SaveAllIndices()
log.Info().Msg("All indices saved successfully")
}()
}

func initQdrant() {
log.Info().Msg("Initializing Qdrant...")
db := qdrant.Init()
db.LoadCentroids(viper.GetString("QDRANT_CENTROID_FILE_PATH"))
}
80 changes: 80 additions & 0 deletions eigenix/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
module github.com/Meesho/skye-eigenix

go 1.24.4

toolchain go1.24.7

require (
github.com/Meesho/go-core v1.30.17
github.com/qdrant/go-client v1.15.2
github.com/rs/zerolog v1.34.0
github.com/spf13/viper v1.20.1
google.golang.org/grpc v1.73.0
google.golang.org/protobuf v1.36.9
)

require (
github.com/DataDog/datadog-go/v5 v5.5.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/bits-and-blooms/bitset v1.22.0 // indirect
github.com/bytedance/sonic v1.14.0 // indirect
github.com/bytedance/sonic/loader v0.3.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/failsafe-go/failsafe-go v0.6.9 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/gin-contrib/sse v1.1.0 // indirect
github.com/gin-gonic/gin v1.11.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.27.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/go-zookeeper/zk v1.0.4 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/goccy/go-yaml v1.18.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/quic-go/qpack v0.5.1 // indirect
github.com/quic-go/quic-go v0.54.0 // indirect
github.com/sagikazarmark/locafero v0.9.0 // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.14.0 // indirect
github.com/spf13/cast v1.9.2 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.11.1 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.3.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.62.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 // indirect
go.opentelemetry.io/otel v1.37.0 // indirect
go.opentelemetry.io/otel/metric v1.37.0 // indirect
go.opentelemetry.io/otel/trace v1.37.0 // indirect
go.uber.org/mock v0.5.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.20.0 // indirect
golang.org/x/crypto v0.40.0 // indirect
golang.org/x/mod v0.25.0 // indirect
golang.org/x/net v0.42.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/text v0.27.0 // indirect
golang.org/x/tools v0.34.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250715232539-7130f93afb79 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading