29 lines
715 B
Go
29 lines
715 B
Go
package workerdiagnostic
|
|
|
|
import (
|
|
"context"
|
|
|
|
v1 "git.5iot.com/iotlcm-public/iotlcm-admin-svr/api/workerdiagnostic/v1"
|
|
workerdiagnosticservice "git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/service/workerdiagnostic"
|
|
)
|
|
|
|
type Controller struct {
|
|
service *workerdiagnosticservice.Service
|
|
}
|
|
|
|
func New(service *workerdiagnosticservice.Service) *Controller {
|
|
return &Controller{service: service}
|
|
}
|
|
|
|
func (c *Controller) Diagnostic(ctx context.Context, req *v1.DiagnosticReq) (*v1.DiagnosticRes, error) {
|
|
result, err := c.service.Publish(ctx, req.Message)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.DiagnosticRes{
|
|
TraceID: result.TraceID,
|
|
Queue: result.Queue,
|
|
SentAt: result.SentAt,
|
|
}, nil
|
|
}
|