Skip to content

Commit

Permalink
Migrating pull request 210 to V2 (topfreegames#228)
Browse files Browse the repository at this point in the history
Co-authored-by: Henrique Oelze <[email protected]>
  • Loading branch information
henriqueoelze and Henrique Oelze authored Aug 3, 2021
1 parent 8f1df9e commit 08bf6b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions metrics/prometheus_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 22,8 @@ package metrics

import (
"fmt"
"log"
"github.com/topfreegames/pitaya/v2/logger"

"net/http"
"sync"

Expand Down Expand Up @@ -299,7 300,10 @@ func getPrometheusReporter(
prometheusReporter.registerMetrics(config.ConstLabels, config.Prometheus.AdditionalLabels, metricsSpecs)
http.Handle("/metrics", promhttp.Handler())
go (func() {
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", config.Prometheus.Port), nil))
err := http.ListenAndServe(fmt.Sprintf(":%d", config.Prometheus.Port), nil)
if err != nil {
logger.Log.Error("prometheus reporter serve start failed, err: ", err)
}
})()
})

Expand Down
8 changes: 6 additions & 2 deletions service/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 210,12 @@ func (r *RemoteService) DoRPC(ctx context.Context, serverID string, route *route
Data: protoData,
}

if serverID == "" {
return r.remoteCall(ctx, nil, protos.RPCType_User, route, nil, msg)
}

target, _ := r.serviceDiscovery.GetServer(serverID)
if serverID != "" && target == nil {
if target == nil {
return nil, constants.ErrServerNotFound
}

Expand Down Expand Up @@ -449,7 453,7 @@ func (r *RemoteService) remoteCall(

res, err := r.rpcClient.Call(ctx, rpcType, route, session, msg, target)
if err != nil {
logger.Log.Errorf("error making call to target with id %s and host %s: %w", target.ID, target.Hostname, err)
logger.Log.Errorf("error making call to target with id %s, route %s and host %s: %w", target.ID, route.String(), target.Hostname, err)
return nil, err
}
return res, err
Expand Down

0 comments on commit 08bf6b3

Please sign in to comment.