mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-20 11:22:31 -05:00
go/utils/remotesrv: Through DBCache through to http server so we can use WriteTableFile eventually.
This commit is contained in:
@@ -38,7 +38,11 @@ var (
|
||||
|
||||
var expectedFiles = make(map[string]*remotesapi.TableFileDetails)
|
||||
|
||||
func ServeHTTP(respWr http.ResponseWriter, req *http.Request) {
|
||||
type filehandler struct {
|
||||
dbCache *DBCache
|
||||
}
|
||||
|
||||
func (filehandler) ServeHTTP(respWr http.ResponseWriter, req *http.Request) {
|
||||
logger := getReqLogger("HTTP_"+req.Method, req.RequestURI)
|
||||
defer func() { logger("finished") }()
|
||||
|
||||
|
||||
@@ -76,30 +76,31 @@ func waitForSignal() {
|
||||
}
|
||||
|
||||
func startServer(httpHost string, httpPort, grpcPort int) (chan interface{}, *sync.WaitGroup) {
|
||||
dbCache := NewLocalCSCache(filesys.LocalFS)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
stopChan := make(chan interface{})
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
httpServer(httpPort, stopChan)
|
||||
httpServer(dbCache, httpPort, stopChan)
|
||||
}()
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
grpcServer(httpHost, grpcPort, stopChan)
|
||||
grpcServer(httpHost, dbCache, grpcPort, stopChan)
|
||||
}()
|
||||
|
||||
return stopChan, &wg
|
||||
}
|
||||
|
||||
func grpcServer(httpHost string, grpcPort int, stopChan chan interface{}) {
|
||||
func grpcServer(httpHost string, dbCache *DBCache, grpcPort int, stopChan chan interface{}) {
|
||||
defer func() {
|
||||
log.Println("exiting grpc Server go routine")
|
||||
}()
|
||||
|
||||
dbCache := NewLocalCSCache(filesys.LocalFS)
|
||||
chnkSt := NewHttpFSBackedChunkStore(httpHost, dbCache)
|
||||
|
||||
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", grpcPort))
|
||||
@@ -120,14 +121,14 @@ func grpcServer(httpHost string, grpcPort int, stopChan chan interface{}) {
|
||||
grpcServer.GracefulStop()
|
||||
}
|
||||
|
||||
func httpServer(httpPort int, stopChan chan interface{}) {
|
||||
func httpServer(dbCache *DBCache, httpPort int, stopChan chan interface{}) {
|
||||
defer func() {
|
||||
log.Println("exiting http Server go routine")
|
||||
}()
|
||||
|
||||
server := http.Server{
|
||||
Addr: fmt.Sprintf(":%d", httpPort),
|
||||
Handler: http.HandlerFunc(ServeHTTP),
|
||||
Handler: filehandler{dbCache},
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
||||
Reference in New Issue
Block a user