cml04-falcon-system/injector/service/service.go

36 lines
811 B
Go
Raw Normal View History

2024-10-04 09:15:48 +02:00
package service
import (
"context"
2024-10-04 09:45:09 +02:00
"time"
2024-10-04 09:15:48 +02:00
"git.espin.casa/albert/cml04-falcon-system/injector/types"
2024-10-04 09:38:25 +02:00
"git.espin.casa/albert/cml04-falcon-system/internal/publisher"
2024-10-04 09:15:48 +02:00
)
type IService interface {
2024-10-04 09:38:25 +02:00
Bundle(ctx context.Context, req *types.PostBundleReq) (res *types.PostBundleRes, err error)
2024-10-04 09:15:48 +02:00
}
2024-10-04 09:38:25 +02:00
type service struct {
pub publisher.Publisher
}
2024-10-04 09:15:48 +02:00
// Bundle implements IService.
2024-10-04 09:38:25 +02:00
func (s *service) Bundle(ctx context.Context, req *types.PostBundleReq) (res *types.PostBundleRes, err error) {
2024-10-04 09:45:09 +02:00
// publish bundle data
if err := s.pub.NewBundle(ctx, req.BundleData); err != nil {
return nil, err
}
return &types.PostBundleRes{
Message: "bundle data posted success",
TimeStamp: time.Now().UTC().Format(time.RFC3339),
}, nil
2024-10-04 09:15:48 +02:00
}
2024-10-04 09:38:25 +02:00
func New(pub publisher.Publisher) IService {
return &service{
pub: pub,
}
2024-10-04 09:15:48 +02:00
}