service.go 864 B

12345678910111213141516171819202122232425262728293031323334
  1. // package service -- главный тип сервиса
  2. package service
  3. import (
  4. "gitp78su.ipnodns.ru/svi/goarch/lev2/mod_http"
  5. "gitp78su.ipnodns.ru/svi/kern/v3"
  6. "gitp78su.ipnodns.ru/svi/kern/v3/krn/ktypes"
  7. . "gitp78su.ipnodns.ru/svi/kern/v3/krn/ktypes"
  8. )
  9. // Service -- тип сервиса
  10. type Service struct {
  11. kCtx IKernelCtx
  12. modHttp *mod_http.ModHttp
  13. }
  14. // NewService -- возвращает новый сервис
  15. func NewService() *Service {
  16. kCtx := kern.GetKernelCtx()
  17. kCtx.Set("monolitName", "SviArch", "NewService()")
  18. sf := &Service{
  19. kCtx: kern.GetKernelCtx(),
  20. modHttp: mod_http.NewModHttp(),
  21. }
  22. return sf
  23. }
  24. // Run -- запуск сервиса
  25. func (sf *Service) Run() ktypes.Result[bool] {
  26. sHttp := sf.kCtx.Get("kServHttp").Val().(ktypes.IKernelServerHttp)
  27. go sHttp.Run()
  28. sf.kCtx.Wg().Wait()
  29. return ktypes.NewOk(true)
  30. }