That project have 2 service:
- GIN - http server run on 7878
- GRPC - grpc server run on 7879
On that page you can see every request on every service together in one transaction
That server have one route which did request on grpc server:
engine.GET("hello", func(context *gin.Context) {
res, err := clint.Echo(context, &service.EchoMsg{})
if err != nil {
context.AbortWithError(200, err)
return
}
context.JSON(200, res)
})
GRPC server accept that request and did http call to external domain:
func (s *server) Echo(ctx context.Context, msg *service.EchoMsg) (*service.EchoMsg, error) {
trx := core.GetTransactionFromContext(ctx).CreateTransaction("calcaulate time", api.TransactionType_TRANSACTION_TYPE_INTERNAL, nil)
client := http.Client{Transport: sHttp.NewRoundTripper(s.application, nil)}
req, err := http.NewRequest("GET", "https://api.exchangeratesapi.io/latest?base=USD", nil)
if err != nil {
return nil, err
}
_, err = client.Do(sHttp.NewRequest(trx, req))
trx.End(nil)
return &service.EchoMsg{}, nil
}
On examples service we have cron with:
0 * * * * /usr/bin/curl http://localhost:7878/hello
It produce transaction every hour all transaction here