forked from chroma-core/chroma
-
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]: Use new log service (chroma-core#1971)
## Description of changes *Summarize the changes made by this PR.* - Improvements & Bug fixes - Use refactored log service ## Test plan *How are these changes tested?* Tested with tilt
- Loading branch information
1 parent
cfc3a75
commit dab637f
Showing
29 changed files
with
197 additions
and
105 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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
**/.DS_Store | ||
|
||
**/__pycache__ | ||
|
||
go/bin/ | ||
go/**/testdata/ | ||
go/coordinator/bin/ | ||
|
||
|
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,36 +1,46 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"context" | ||
"github.com/chroma-core/chroma/go/pkg/log/configuration" | ||
"github.com/chroma-core/chroma/go/pkg/log/repository" | ||
"github.com/chroma-core/chroma/go/pkg/log/server" | ||
"github.com/chroma-core/chroma/go/pkg/proto/logservicepb" | ||
"github.com/chroma-core/chroma/go/pkg/utils" | ||
libs "github.com/chroma-core/chroma/go/shared/libs" | ||
"github.com/pingcap/log" | ||
"github.com/rs/zerolog" | ||
"github.com/spf13/cobra" | ||
"go.uber.org/automaxprocs/maxprocs" | ||
"go.uber.org/zap" | ||
"google.golang.org/grpc" | ||
"net" | ||
) | ||
|
||
var ( | ||
rootCmd = &cobra.Command{ | ||
Use: "logservice", | ||
Short: "RecordLog root command", | ||
Long: `RecordLog root command`, | ||
} | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(Cmd) | ||
} | ||
|
||
func main() { | ||
ctx := context.Background() | ||
// Configure logger | ||
utils.LogLevel = zerolog.DebugLevel | ||
utils.ConfigureLogger() | ||
if _, err := maxprocs.Set(); err != nil { | ||
_, _ = fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
log.Fatal("can't set maxprocs", zap.Error(err)) | ||
} | ||
log.Info("Starting log service") | ||
config := configuration.NewLogServiceConfiguration() | ||
conn, err := libs.NewPgConnection(ctx, config) | ||
if err != nil { | ||
log.Fatal("failed to connect to postgres", zap.Error(err)) | ||
} | ||
lr := repository.NewLogRepository(conn) | ||
server := server.NewLogServer(lr) | ||
var listener net.Listener | ||
listener, err = net.Listen("tcp", ":"+config.PORT) | ||
if err != nil { | ||
log.Fatal("failed to listen", zap.Error(err)) | ||
} | ||
if err := rootCmd.Execute(); err != nil { | ||
_, _ = fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
s := grpc.NewServer() | ||
logservicepb.RegisterLogServiceServer(s, server) | ||
log.Info("log service started", zap.String("address", listener.Addr().String())) | ||
if err := s.Serve(listener); err != nil { | ||
log.Fatal("failed to serve", zap.Error(err)) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
h1:l718NRul/xO5Vz4nKzlWAR9ML+kOkn4TTgIlMQYcUZA= | ||
20240401221053_initial.sql h1:RPywT3bZIeCHgfStvajW3fcDhqadDY5xI9MFjE/Un4U= | ||
h1:kG+ejV1DS3youx+m5SNNFYabJeDqfYTdSQHbJtR2/eU= | ||
20240404181827_initial.sql h1:xnoD1FcXImqQPJOvaDbTOwTGPLtCP3RibetuaaZeATI= |
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 @@ | ||
package configuration | ||
|
||
import "os" | ||
|
||
type LogServiceConfiguration struct { | ||
PORT string | ||
DATABASE_URL string | ||
} | ||
|
||
func getEnvWithDefault(key, defaultValue string) string { | ||
value := os.Getenv(key) | ||
if value == "" { | ||
return defaultValue | ||
} | ||
return value | ||
} | ||
|
||
func NewLogServiceConfiguration() *LogServiceConfiguration { | ||
return &LogServiceConfiguration{ | ||
PORT: getEnvWithDefault("PORT", "50051"), | ||
DATABASE_URL: getEnvWithDefault("CHROMA_DATABASE_URL", "postgresql://chroma:[email protected]:5432/log"), | ||
} | ||
} |
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
Oops, something went wrong.