NewService creates a new Evaluation service
(opts ...service.Option[*Service])
| 140 | |
| 141 | // NewService creates a new Evaluation service |
| 142 | func NewService(opts ...service.Option[*Service]) *Service { |
| 143 | var err error |
| 144 | svc := Service{ |
| 145 | orchestrator: api.NewRPCConnection(DefaultOrchestratorAddress, orchestrator.NewOrchestratorClient), |
| 146 | scheduler: gocron.NewScheduler(time.Local), |
| 147 | catalogControls: make(map[string]map[string]*orchestrator.Control), |
| 148 | } |
| 149 | |
| 150 | // Apply service options |
| 151 | for _, o := range opts { |
| 152 | o(&svc) |
| 153 | } |
| 154 | |
| 155 | // Default to an in-memory storage, if nothing was explicitly set |
| 156 | if svc.storage == nil { |
| 157 | svc.storage, err = inmemory.NewStorage() |
| 158 | if err != nil { |
| 159 | log.Errorf("Could not initialize the storage: %v", err) |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | // Default to an allow-all authorization strategy |
| 164 | if svc.authz == nil { |
| 165 | svc.authz = &service.AuthorizationStrategyAllowAll{} |
| 166 | } |
| 167 | |
| 168 | return &svc |
| 169 | } |
| 170 | |
| 171 | func (svc *Service) Init() {} |
| 172 |