Skip to content

Commit

Permalink
[ENH] Add system-catalog-provider to simplify deployment (#1358)
Browse files Browse the repository at this point in the history
## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - This adds a system-catalog-provider config to simplify deployment
 - New functionality
	 - ...

## Test plan
*How are these changes tested?*

- [ ] test_system.py

## Documentation Changes
*Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
repository](https://github.com/chroma-core/docs)?*
  • Loading branch information
Ishiihara authored Nov 8, 2023
1 parent a14f158 commit 7d5b179
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions go/coordinator/cmd/grpccoordinator/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (

func init() {
flag.GRPCAddr(Cmd, &conf.BindAddress)
Cmd.Flags().StringVar(&conf.SystemCatalogProvider, "system-catalog-provider", "memory", "System catalog provider")
Cmd.Flags().StringVar(&conf.Username, "username", "root", "MetaTable username")
Cmd.Flags().StringVar(&conf.Password, "password", "", "MetaTable password")
Cmd.Flags().StringVar(&conf.Address, "db-address", "127.0.0.1:3306", "MetaTable db address")
Expand Down
38 changes: 25 additions & 13 deletions go/coordinator/internal/grpccoordinator/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package grpccoordinator

import (
"context"
"errors"

"github.com/chroma/chroma-coordinator/internal/coordinator"
"github.com/chroma/chroma-coordinator/internal/grpccoordinator/grpcutils"
"github.com/chroma/chroma-coordinator/internal/metastore/db/dbcore"
"github.com/chroma/chroma-coordinator/internal/proto/coordinatorpb"
"google.golang.org/grpc"
"google.golang.org/grpc/health"
Expand All @@ -15,6 +17,9 @@ type Config struct {
// GRPC config
BindAddress string

// System catalog provider
SystemCatalogProvider string

// MetaTable config
Username string
Password string
Expand All @@ -39,19 +44,26 @@ type Server struct {
}

func New(config Config) (*Server, error) {
// dBConfig := dbcore.DBConfig{
// Username: config.Username,
// Password: config.Password,
// Address: config.Address,
// DBName: config.DBName,
// MaxIdleConns: config.MaxIdleConns,
// MaxOpenConns: config.MaxOpenConns,
// }
// db, err := dbcore.Connect(dBConfig)
// if err != nil {
// return nil, err
// }
return NewWithGrpcProvider(config, grpcutils.Default, nil)
if config.SystemCatalogProvider == "memory" {
return NewWithGrpcProvider(config, grpcutils.Default, nil)
} else if config.SystemCatalogProvider == "database" {
dBConfig := dbcore.DBConfig{
Username: config.Username,
Password: config.Password,
Address: config.Address,
DBName: config.DBName,
MaxIdleConns: config.MaxIdleConns,
MaxOpenConns: config.MaxOpenConns,
}
db, err := dbcore.Connect(dBConfig)
if err != nil {
return nil, err
}
return NewWithGrpcProvider(config, grpcutils.Default, db)
} else {
return nil, errors.New("invalid system catalog provider, only memory and database are supported")
}

}

func NewWithGrpcProvider(config Config, provider grpcutils.GrpcProvider, db *gorm.DB) (*Server, error) {
Expand Down
6 changes: 1 addition & 5 deletions k8s/deployment/kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,6 @@ spec:
- command:
- "chroma"
- "coordinator"
- "--db-address=aws.connect.psdb.cloud"
- "--username=pscale_user"
- "--password=pscale_password"
- "--db-name=test"
image: chroma-coordinator
imagePullPolicy: IfNotPresent
name: coordinator
Expand All @@ -293,4 +289,4 @@ spec:
targetPort: grpc
selector:
app: coordinator
type: ClusterIP
type: ClusterIP

0 comments on commit 7d5b179

Please sign in to comment.