Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
ValyaB committed Sep 18, 2024
1 parent 779f74c commit 9379611
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
12 changes: 6 additions & 6 deletions cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import (
"runtime"
"time"

"cloud-proxy/internal/cloud/gcp"
"cloud-proxy/internal/cloud/gcp/gcpauth"
"cloud-proxy/internal/config"
"cloud-proxy/internal/healthz"
"cloud-proxy/internal/proxy"

"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"

"cloud-proxy/internal/cloud/gcp"
"cloud-proxy/internal/cloud/gcp/gcpauth"
"cloud-proxy/internal/config"
"cloud-proxy/internal/healthz"
"cloud-proxy/internal/proxy"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ type Config struct {

PodMetadata PodMetadata `mapstructure:"podmetadata"`

// MetricsAddress string `mapstructure:"metricsaddress"`
// MetricsAddress string `mapstructure:"metricsaddress"`.
HealthAddress string `mapstructure:"healthaddress"`
Log Log `mapstructure:"log"`
Log Log `mapstructure:"log"`
}

// PodMetadata stores metadata for the pod, mostly used for logging and debugging purposes.
Expand Down
13 changes: 10 additions & 3 deletions internal/healthz/healthz.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package healthz
import (
"encoding/json"
"net/http"
"time"

"github.com/sirupsen/logrus"
)
Expand All @@ -23,10 +24,16 @@ func (hc *Server) Run(addr string) error {
mux.HandleFunc("/readyz", hc.readyCheck)
mux.HandleFunc("/livez", hc.liveCheck)

return http.ListenAndServe(addr, mux)
server := &http.Server{
Addr: addr,
ReadHeaderTimeout: 3 * time.Second,
Handler: mux,
}

return server.ListenAndServe()
}

func (hc *Server) readyCheck(w http.ResponseWriter, r *http.Request) {
func (hc *Server) readyCheck(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("content-type", "application/json")

// TODO: Implement proper readiness checks.
Expand All @@ -49,7 +56,7 @@ func (hc *Server) readyCheck(w http.ResponseWriter, r *http.Request) {
}
}

func (hc *Server) liveCheck(w http.ResponseWriter, r *http.Request) {
func (hc *Server) liveCheck(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("content-type", "application/json")

// TODO: Implement proper liveness checks.
Expand Down

0 comments on commit 9379611

Please sign in to comment.