initial commit 2
This commit is contained in:
45
domain/service/service.go
Normal file
45
domain/service/service.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"bitbucket.org/nemt/nemt-portal-api/domain/contract"
|
||||
"bitbucket.org/nemt/nemt-portal-api/infra/config"
|
||||
"bitbucket.org/nemt/nemt-portal-api/infra/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
instance *Service
|
||||
once sync.Once
|
||||
)
|
||||
|
||||
// Service holds the domain service repositories
|
||||
type Service struct {
|
||||
db contract.DataManager
|
||||
cache contract.CacheManager
|
||||
tnc contract.TNCManager
|
||||
Users *userService
|
||||
Rides *rideService
|
||||
Visits *visitService
|
||||
Provider *providerService
|
||||
Notification *notificationService
|
||||
Profile *profileService
|
||||
Organization *organizationService
|
||||
}
|
||||
|
||||
// New returns a new domain Service instance
|
||||
func New(db contract.DataManager, cache contract.CacheManager, cfg *config.Config, log *logger.Logger) (*Service, error) {
|
||||
once.Do(func() {
|
||||
instance = &Service{db: db, cache: cache}
|
||||
|
||||
instance.Users = newUserService(instance)
|
||||
instance.Rides = newRideService(instance)
|
||||
instance.Visits = newVisitService(instance)
|
||||
instance.Provider = newProviderService(instance)
|
||||
instance.Notification = newNotificationService(instance)
|
||||
instance.Profile = newProfileService(instance)
|
||||
instance.Organization = newOrganizationService(instance)
|
||||
})
|
||||
|
||||
return instance, nil
|
||||
}
|
||||
Reference in New Issue
Block a user