transcoderlogic.go 774 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package logic
  2. import (
  3. "audio_transcoder/internal/svc"
  4. "audio_transcoder/internal/types"
  5. "audio_transcoder/job"
  6. "context"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type TranscoderLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewTranscoderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TranscoderLogic {
  15. return &TranscoderLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *TranscoderLogic) Transcoder(req *types.Request) (resp *types.Response, err error) {
  22. transcoder, err := job.Transcoder(l.svcCtx, &types.CallbackRequest{Path: req.Path})
  23. if err != nil {
  24. return nil, err
  25. }
  26. resp = &types.Response{
  27. Path: transcoder.Path,
  28. Message: transcoder.Message,
  29. }
  30. return
  31. }