libs5-go/node/services.go

45 lines
902 B
Go
Raw Normal View History

2024-01-07 09:15:28 +00:00
package node
import (
"git.lumeweb.com/LumeWeb/libs5-go/service"
)
2024-01-07 09:15:28 +00:00
var (
_ service.Services = (*ServicesImpl)(nil)
2024-01-07 09:15:28 +00:00
)
type ServicesImpl struct {
p2p *service.P2PService
registry *service.RegistryService
http *service.HTTPService
}
func (s *ServicesImpl) HTTP() *service.HTTPService {
return s.http
2024-01-10 11:21:03 +00:00
}
func (s *ServicesImpl) All() []service.Service {
services := make([]service.Service, 0)
services = append(services, s.p2p)
services = append(services, s.registry)
services = append(services, s.http)
return services
}
func (s *ServicesImpl) Registry() *service.RegistryService {
2024-01-10 11:21:03 +00:00
return s.registry
2024-01-07 09:15:28 +00:00
}
func NewServices(p2p *service.P2PService, registry *service.RegistryService, http *service.HTTPService) service.Services {
return &ServicesImpl{
p2p: p2p,
registry: registry,
http: http,
}
2024-01-07 09:15:28 +00:00
}
func (s *ServicesImpl) P2P() *service.P2PService {
2024-01-07 09:15:28 +00:00
return s.p2p
}