-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Liquan Pei
authored and
Liquan Pei
committed
Oct 23, 2023
1 parent
9d89b96
commit 858a086
Showing
54 changed files
with
6,938 additions
and
37 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
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
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
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
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
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
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
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,23 @@ | ||
FROM golang:1.20-alpine as build | ||
|
||
RUN apk add --no-cache make git build-base bash | ||
|
||
ENV PATH=$PATH:/go/bin | ||
ADD ./go/coordinator /src/chroma-coordinator | ||
|
||
RUN cd /src/chroma-coordinator \ | ||
&& make | ||
|
||
FROM alpine:3.17.3 | ||
|
||
RUN apk add --no-cache bash bash-completion | ||
|
||
RUN mkdir /chroma-coordinator | ||
WORKDIR /chroma-coordinator | ||
|
||
COPY --from=build /src/chroma-coordinator/bin/chroma /chroma-coordinator/bin/chroma | ||
ENV PATH=$PATH:/chroma-coordinator/bin | ||
|
||
RUN chroma completion bash > ~/.bashrc | ||
|
||
CMD /bin/bash |
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,56 @@ | ||
.PHONY: build | ||
build: | ||
go build -v -o bin/chroma ./cmd | ||
|
||
test: build | ||
go test -cover -race ./... | ||
|
||
lint: | ||
#brew install golangci-lint | ||
golangci-lint run | ||
|
||
clean: | ||
rm -f bin/chroma | ||
|
||
docker: | ||
docker build -t chroma-coordinator:latest . | ||
|
||
docker_multi_arch: | ||
docker buildx build --platform linux/x86_64,linux/arm64 -t oxia:latest . | ||
|
||
.PHONY: proto | ||
proto: | ||
cd proto && \ | ||
protoc \ | ||
--go_out=. \ | ||
--go_opt paths=source_relative \ | ||
--plugin protoc-gen-go="${GOPATH}/bin/protoc-gen-go" \ | ||
--go-grpc_out=. \ | ||
--go-grpc_opt paths=source_relative \ | ||
--plugin protoc-gen-go-grpc="${GOPATH}/bin/protoc-gen-go-grpc" \ | ||
--go-vtproto_out=. \ | ||
--go-vtproto_opt paths=source_relative \ | ||
--plugin protoc-gen-go-vtproto="${GOPATH}/bin/protoc-gen-go-vtproto" \ | ||
--go-vtproto_opt=features=marshal+unmarshal+size+pool+equal+clone \ | ||
*.proto | ||
|
||
proto_clean: | ||
rm -f */*.pb.go | ||
|
||
proto_format: | ||
#brew install clang-format | ||
clang-format -i --style=Google proto/*.proto | ||
|
||
proto_lint: | ||
#go install github.com/yoheimuta/protolint/cmd/protoc-gen-protolint | ||
protoc --proto_path ./proto \ | ||
--protolint_out . \ | ||
--protolint_opt config_dir_path=. \ | ||
--protolint_opt proto_root=./proto \ | ||
proto/*.proto | ||
|
||
proto_doc: | ||
#go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc | ||
protoc --doc_out=docs/proto --doc_opt=markdown,proto.md proto/*.proto | ||
|
||
proto_quality: proto_format proto_lint |
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,15 @@ | ||
package flag | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
const ( | ||
DefaultGRPCPort = 50051 | ||
) | ||
|
||
func GRPCAddr(cmd *cobra.Command, conf *string) { | ||
cmd.Flags().StringVarP(conf, "grpc-addr", "g", fmt.Sprintf("0.0.0.0:%d", DefaultGRPCPort), "GRPC service bind address") | ||
} |
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,38 @@ | ||
package grpccoordinator | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/chroma/chroma-coordinator/cmd/flag" | ||
"github.com/chroma/chroma-coordinator/internal/grpccoordinator" | ||
"github.com/chroma/chroma-coordinator/internal/utils" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
conf = grpccoordinator.Config{} | ||
|
||
Cmd = &cobra.Command{ | ||
Use: "coordinator", | ||
Short: "Start a coordinator", | ||
Long: `Long description`, | ||
Run: exec, | ||
} | ||
) | ||
|
||
func init() { | ||
flag.GRPCAddr(Cmd, &conf.BindAddress) | ||
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") | ||
Cmd.Flags().StringVar(&conf.DBName, "db-name", "", "MetaTable db name") | ||
Cmd.Flags().IntVar(&conf.MaxIdleConns, "max-idle-conns", 10, "MetaTable max idle connections") | ||
Cmd.Flags().IntVar(&conf.MaxOpenConns, "max-open-conns", 10, "MetaTable max open connections") | ||
} | ||
|
||
func exec(*cobra.Command, []string) { | ||
utils.RunProcess(func() (io.Closer, error) { | ||
return grpccoordinator.New(conf) | ||
}) | ||
} |
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,37 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/chroma/chroma-coordinator/cmd/grpccoordinator" | ||
"github.com/chroma/chroma-coordinator/internal/utils" | ||
"github.com/rs/zerolog" | ||
"github.com/spf13/cobra" | ||
"go.uber.org/automaxprocs/maxprocs" | ||
) | ||
|
||
var ( | ||
rootCmd = &cobra.Command{ | ||
Use: "chroma", | ||
Short: "Chroma root command", | ||
Long: `Chroma root command`, | ||
} | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(grpccoordinator.Cmd) | ||
} | ||
|
||
func main() { | ||
utils.LogLevel = zerolog.DebugLevel | ||
utils.ConfigureLogger() | ||
if _, err := maxprocs.Set(); err != nil { | ||
_, _ = fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
if err := rootCmd.Execute(); err != nil { | ||
_, _ = fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
go/coordinator/deploy/charts/chroma-coordinator/Chart.yaml
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,12 @@ | ||
apiVersion: v2 | ||
name: chroma-coordinator | ||
description: Chroma Coorindator | ||
type: application | ||
version: 0.0.1 | ||
appVersion: "0.0.1" | ||
home: https://www.trychroma.com/ | ||
sources: | ||
- https://github.com/chroma-core/chroma | ||
maintainers: | ||
- name: Chroma Support | ||
email: [email protected] |
Oops, something went wrong.