// Code generated by candi v1.5.6. DO NOT EDIT.

package masterservice

import (
	"pkg.agungdp.dev/candi/codebase/factory"
	"pkg.agungdp.dev/candi/codebase/factory/appfactory"
	"pkg.agungdp.dev/candi/codebase/factory/dependency"
	"pkg.agungdp.dev/candi/codebase/factory/types"
	"pkg.agungdp.dev/candi/config"

	"monorepo/services/master-service/configs"
	"monorepo/services/master-service/internal/modules/acl"
	"monorepo/services/master-service/internal/modules/apps"
)

// Service model
type Service struct {
	cfg          *config.Config
	deps         dependency.Dependency
	applications []factory.AppServerFactory
	modules      []factory.ModuleFactory
	name         types.Service
}

// NewService in this service
func NewService(serviceName string, cfg *config.Config) factory.ServiceFactory {
	deps := configs.LoadConfigs(cfg)

	modules := []factory.ModuleFactory{
		acl.NewModule(deps),
		apps.NewModule(deps),
	}

	s := &Service{
		cfg:     cfg,
		deps:    deps,
		modules: modules,
		name:    types.Service(cfg.ServiceName),
	}

	s.applications = appfactory.NewAppFromEnvironmentConfig(s)

	// Add custom application runner, must implement `factory.AppServerFactory` methods
	s.applications = append(s.applications, []factory.AppServerFactory{
		// customApplication
	}...)

	return s
}

// GetConfig method
func (s *Service) GetConfig() *config.Config {
	return s.cfg
}

// GetDependency method
func (s *Service) GetDependency() dependency.Dependency {
	return s.deps
}

// GetApplications method
func (s *Service) GetApplications() []factory.AppServerFactory {
	return s.applications
}

// GetModules method
func (s *Service) GetModules() []factory.ModuleFactory {
	return s.modules
}

// Name method
func (s *Service) Name() types.Service {
	return s.name
}
