37 lines
820 B
Go
37 lines
820 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"git.espin.casa/albert/cml04-falcon-system/injector/types"
|
|
"git.espin.casa/albert/cml04-falcon-system/internal/publisher"
|
|
)
|
|
|
|
type IService interface {
|
|
Bundle(ctx context.Context, req *types.PostBundleReq) (res *types.PostBundleRes, err error)
|
|
}
|
|
|
|
type service struct {
|
|
pub publisher.Publisher
|
|
}
|
|
|
|
// Bundle implements IService.
|
|
func (s *service) Bundle(ctx context.Context, req *types.PostBundleReq) (res *types.PostBundleRes, err error) {
|
|
// publish bundle data
|
|
if err := s.pub.NewBundle(ctx, req.BundleData); err != nil {
|
|
return nil, err
|
|
}
|
|
// done
|
|
return &types.PostBundleRes{
|
|
Message: "bundle data posted success",
|
|
TimeStamp: time.Now().UTC().Format(time.RFC3339),
|
|
}, nil
|
|
}
|
|
|
|
func New(pub publisher.Publisher) IService {
|
|
return &service{
|
|
pub: pub,
|
|
}
|
|
}
|