|
|
|
@ -7,11 +7,14 @@ |
|
|
|
package dtmsvr |
|
|
|
|
|
|
|
import ( |
|
|
|
"context" |
|
|
|
"fmt" |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/dtm-labs/dtm/dtmcli" |
|
|
|
"github.com/dtm-labs/dtm/dtmcli/logger" |
|
|
|
"github.com/dtm-labs/dtm/dtmgrpc" |
|
|
|
"github.com/dtm-labs/dtm/dtmgrpc/dtmgimp" |
|
|
|
"github.com/dtm-labs/dtm/dtmgrpc/dtmgpb" |
|
|
|
"github.com/dtm-labs/dtm/dtmutil" |
|
|
|
@ -23,6 +26,12 @@ import ( |
|
|
|
// StartSvr StartSvr
|
|
|
|
func StartSvr() { |
|
|
|
logger.Infof("start dtmsvr") |
|
|
|
dtmcli.GetRestyClient().SetTimeout(time.Duration(conf.RequestTimeout) * time.Second) |
|
|
|
dtmgrpc.AddUnaryInterceptor(func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { |
|
|
|
ctx2, cancel := context.WithTimeout(ctx, time.Duration(conf.RequestTimeout)*time.Second) |
|
|
|
defer cancel() |
|
|
|
return invoker(ctx2, method, req, reply, cc, opts...) |
|
|
|
}) |
|
|
|
app := dtmutil.GetGinApp() |
|
|
|
app = httpMetrics(app) |
|
|
|
addRoute(app) |
|
|
|
|