Skip to content

Commit a852848

Browse files
committed
Merge branch 'dev' into delete-child-comments
2 parents 775b2ca + 3185f98 commit a852848

File tree

8 files changed

+32
-0
lines changed

8 files changed

+32
-0
lines changed

code/grpc-gateway/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"log"
1414
"net/http"
1515
"os"
16+
gorun "runtime"
1617

1718
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
1819
"google.golang.org/grpc"
@@ -108,6 +109,9 @@ func handleHealthCheck(w http.ResponseWriter, r *http.Request) {
108109
}
109110

110111
func main() {
112+
// Set maximum number of CPUs to use
113+
gorun.GOMAXPROCS(gorun.NumCPU())
114+
111115
gwmux := runtime.NewServeMux()
112116

113117
opts := []grpc.DialOption{

code/services/comment-service/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"log"
1010
"net"
1111
"os"
12+
"runtime"
1213

1314
"google.golang.org/grpc"
1415
"google.golang.org/grpc/credentials/insecure"
@@ -38,6 +39,9 @@ func connectGrpcClient(hostEnvVar string, portEnvVar string) *grpc.ClientConn {
3839
}
3940

4041
func main() {
42+
// Set maximum number of CPUs to use
43+
runtime.GOMAXPROCS(runtime.NumCPU())
44+
4145
// connect to database service
4246
dbConn := connectGrpcClient("DB_SERVICE_HOST", "DB_SERVICE_PORT")
4347
defer dbConn.Close()

code/services/community-service/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"log"
1010
"net"
1111
"os"
12+
"runtime"
1213

1314
"google.golang.org/grpc"
1415
"google.golang.org/grpc/credentials/insecure"
@@ -38,6 +39,9 @@ func connectGrpcClient(hostEnvVar string, portEnvVar string) *grpc.ClientConn {
3839
}
3940

4041
func main() {
42+
// Set maximum number of CPUs to use
43+
runtime.GOMAXPROCS(runtime.NumCPU())
44+
4145
// connect to services
4246
dbConn := connectGrpcClient("DB_SERVICE_HOST", "DB_SERVICE_PORT")
4347
defer dbConn.Close()

code/services/db-service/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"log"
99
"net"
1010
"os"
11+
"runtime"
1112
"time"
1213

1314
"go.mongodb.org/mongo-driver/mongo"
@@ -16,6 +17,9 @@ import (
1617
)
1718

1819
func main() {
20+
// Set maximum number of CPUs to use
21+
runtime.GOMAXPROCS(runtime.NumCPU())
22+
1923
mongoURI := os.Getenv("MONGO_URI")
2024
if mongoURI == "" {
2125
log.Fatalf("missing MONGO_URI env var")

code/services/popular-service/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"net"
1010
"os"
1111
server "popular-service/src"
12+
"runtime"
1213

1314
"google.golang.org/grpc"
1415
"google.golang.org/grpc/credentials/insecure"
@@ -38,6 +39,9 @@ func connectGrpcClient(hostEnvVar string, portEnvVar string) *grpc.ClientConn {
3839
}
3940

4041
func main() {
42+
// Set maximum number of CPUs to use
43+
runtime.GOMAXPROCS(runtime.NumCPU())
44+
4145
// Connect to other services
4246
threadConn := connectGrpcClient("THREAD_SERVICE_HOST", "THREAD_SERVICE_PORT")
4347
defer threadConn.Close()

code/services/search-service/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"log"
99
"net"
1010
"os"
11+
"runtime"
1112
server "search-service/src"
1213

1314
"google.golang.org/grpc"
@@ -38,6 +39,9 @@ func connectGrpcClient(hostEnvVar string, portEnvVar string) *grpc.ClientConn {
3839
}
3940

4041
func main() {
42+
// Set maximum number of CPUs to use
43+
runtime.GOMAXPROCS(runtime.NumCPU())
44+
4145
// connect to other services
4246
communityConn := connectGrpcClient("COMMUNITY_SERVICE_HOST", "COMMUNITY_SERVICE_PORT")
4347
defer communityConn.Close()

code/services/thread-service/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"log"
1010
"net"
1111
"os"
12+
"runtime"
1213
server "thread-service/src"
1314

1415
"google.golang.org/grpc"
@@ -39,6 +40,9 @@ func connectGrpcClient(hostEnvVar string, portEnvVar string) *grpc.ClientConn {
3940
}
4041

4142
func main() {
43+
// Set maximum number of CPUs to use
44+
runtime.GOMAXPROCS(runtime.NumCPU())
45+
4246
// connect to database service
4347
dbConn := connectGrpcClient("DB_SERVICE_HOST", "DB_SERVICE_PORT")
4448
defer dbConn.Close()

code/services/vote-service/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"log"
99
"net"
1010
"os"
11+
"runtime"
1112
server "vote-service/src"
1213

1314
"google.golang.org/grpc"
@@ -38,6 +39,9 @@ func connectGrpcClient(hostEnvVar string, portEnvVar string) *grpc.ClientConn {
3839
}
3940

4041
func main() {
42+
// Set maximum number of CPUs to use
43+
runtime.GOMAXPROCS(runtime.NumCPU())
44+
4145
// connect to other services
4246
threadConn := connectGrpcClient("THREAD_SERVICE_HOST", "THREAD_SERVICE_PORT")
4347
defer threadConn.Close()

0 commit comments

Comments
 (0)