github.com/e154/smart-home@v0.17.2-0.20240311175135-e530a6e5cd45/system/supervisor/service.go (about)

     1  // This file is part of the Smart Home
     2  // Program complex distribution https://github.com/e154/smart-home
     3  // Copyright (C) 2016-2023, Filippov Alex
     4  //
     5  // This library is free software: you can redistribute it and/or
     6  // modify it under the terms of the GNU Lesser General Public
     7  // License as published by the Free Software Foundation; either
     8  // version 3 of the License, or (at your option) any later version.
     9  //
    10  // This library is distributed in the hope that it will be useful,
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13  // Library General Public License for more details.
    14  //
    15  // You should have received a copy of the GNU Lesser General Public
    16  // License along with this library.  If not, see
    17  // <https://www.gnu.org/licenses/>.
    18  
    19  package supervisor
    20  
    21  import (
    22  	"github.com/e154/smart-home/adaptors"
    23  	"github.com/e154/smart-home/common/web"
    24  	"github.com/e154/smart-home/models"
    25  	"github.com/e154/smart-home/system/bus"
    26  	"github.com/e154/smart-home/system/mqtt"
    27  	"github.com/e154/smart-home/system/scheduler"
    28  	"github.com/e154/smart-home/system/scripts"
    29  )
    30  
    31  type service struct {
    32  	bus           bus.Bus
    33  	adaptors      *adaptors.Adaptors
    34  	supervisor    Supervisor
    35  	scriptService scripts.ScriptService
    36  	mqttServ      mqtt.MqttServ
    37  	appConfig     *models.AppConfig
    38  	scheduler     *scheduler.Scheduler
    39  	crawler       web.Crawler
    40  }
    41  
    42  // Plugins ...
    43  func (s service) Plugins() map[string]Pluggable {
    44  	list := make(map[string]Pluggable)
    45  	pluginList.Range(func(key, value interface{}) bool {
    46  		name := key.(string)
    47  		list[name] = value.(Pluggable)
    48  		return true
    49  	})
    50  	return list
    51  }
    52  
    53  // EventBus ...
    54  func (s service) EventBus() bus.Bus {
    55  	return s.bus
    56  }
    57  
    58  // Supervisor ...
    59  func (s service) Supervisor() Supervisor {
    60  	return s.supervisor
    61  }
    62  
    63  // Adaptors ...
    64  func (s service) Adaptors() *adaptors.Adaptors {
    65  	return s.adaptors
    66  }
    67  
    68  // ScriptService ...
    69  func (s service) ScriptService() scripts.ScriptService {
    70  	return s.scriptService
    71  }
    72  
    73  // MqttServ ...
    74  func (s service) MqttServ() mqtt.MqttServ {
    75  	return s.mqttServ
    76  }
    77  
    78  // AppConfig ...
    79  func (s service) AppConfig() *models.AppConfig {
    80  	return s.appConfig
    81  }
    82  
    83  // Scheduler ...
    84  func (s service) Scheduler() *scheduler.Scheduler {
    85  	return s.scheduler
    86  }
    87  
    88  // Crawler ...
    89  func (s service) Crawler() web.Crawler {
    90  	return s.crawler
    91  }