42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package quotation
|
|
|
|
import (
|
|
"github.com/tech/sendico/payments/storage"
|
|
"github.com/tech/sendico/pkg/api/routers"
|
|
"github.com/tech/sendico/pkg/mlogger"
|
|
quotationv1 "github.com/tech/sendico/pkg/proto/payments/quotation/v1"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
// QuotationService exposes only quotation RPCs as a standalone gRPC service.
|
|
type QuotationService struct {
|
|
core *Service
|
|
quote *quotationService
|
|
}
|
|
|
|
// NewQuotationService constructs a standalone quotation service.
|
|
func NewQuotationService(logger mlogger.Logger, repo storage.Repository, opts ...Option) *QuotationService {
|
|
core := NewService(logger, repo, opts...)
|
|
return &QuotationService{
|
|
core: core,
|
|
quote: newQuotationService(core),
|
|
}
|
|
}
|
|
|
|
// Register attaches only the quotation service to the supplied gRPC router.
|
|
func (s *QuotationService) Register(router routers.GRPC) error {
|
|
if s == nil || s.quote == nil {
|
|
return nil
|
|
}
|
|
return router.Register(func(reg grpc.ServiceRegistrar) {
|
|
quotationv1.RegisterQuotationServiceServer(reg, s.quote)
|
|
})
|
|
}
|
|
|
|
// Shutdown releases resources used by the underlying core service.
|
|
func (s *QuotationService) Shutdown() {
|
|
if s != nil && s.core != nil {
|
|
s.core.Shutdown()
|
|
}
|
|
}
|