fabrics.go 904 B

1234567891011121314151617181920212223242526272829303132
  1. // package fabrics -- грязная фабрика объектов
  2. package fabrics
  3. import (
  4. "fmt"
  5. "log"
  6. "adt/intertnal/serv_http"
  7. "adt/intertnal/serv_process"
  8. "adt/intertnal/service"
  9. "adt/intertnal/store_ram"
  10. "adt/pkg/types"
  11. )
  12. // MakeService -- возвращает новый объект сервиса
  13. func MakeService() (types.IService, error) {
  14. log.Println("MakeService()")
  15. store := store_ram.NewStoreRam()
  16. servProcess, err := serv_process.NewServProcess(store)
  17. if err != nil {
  18. return nil, fmt.Errorf("MakeService(): in create ServProcess, err=\n\t%w", err)
  19. }
  20. servHttp, err := serv_http.NewServHttp(servProcess)
  21. if err != nil {
  22. return nil, fmt.Errorf("MakeService(): in create ServHttp, err=\n\t%w", err)
  23. }
  24. sf, err := service.NewService(store, servHttp)
  25. if err != nil {
  26. return nil, fmt.Errorf("MakeService(): in service.NewService, err=\n\t%w", err)
  27. }
  28. return sf, nil
  29. }