-
Notifications
You must be signed in to change notification settings - Fork 9
/
services.go
45 lines (34 loc) · 1.1 KB
/
services.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package service
import (
"context"
"errors"
"github.com/IceWhaleTech/CasaOS-MessageBus/repository"
)
type Services struct {
EventTypeService *EventTypeService
EventServiceWS *EventServiceWS
ActionTypeService *ActionTypeService
ActionServiceWS *ActionServiceWS
SocketIOService *SocketIOService
}
var (
ErrInboundChannelNotFound = errors.New("inbound channel not found")
ErrSubscriberChannelsNotFound = errors.New("subscriber channels not found")
ErrAlreadySubscribed = errors.New("already subscribed")
)
func (s *Services) Start(ctx *context.Context) {
go s.EventServiceWS.Start(ctx)
go s.ActionServiceWS.Start(ctx)
go s.SocketIOService.Start(ctx)
}
func NewServices(repository *repository.Repository) Services {
eventTypeService := NewEventTypeService(repository)
actionTypeService := NewActionTypeService(repository)
return Services{
EventTypeService: eventTypeService,
EventServiceWS: NewEventServiceWS(eventTypeService),
SocketIOService: NewSocketIOService(),
ActionTypeService: actionTypeService,
ActionServiceWS: NewActionServiceWS(actionTypeService),
}
}