feat(dns): add explicit service startup wrappers
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
56be52f7bb
commit
fb7236bf12
2 changed files with 28 additions and 0 deletions
|
|
@ -34,6 +34,13 @@ func (server *HealthServer) Address() string {
|
|||
return server.HealthAddress()
|
||||
}
|
||||
|
||||
// StartHealthServer is an explicit convenience wrapper around ServeHTTPHealth.
|
||||
//
|
||||
// health, err := service.StartHealthServer("127.0.0.1", 5554)
|
||||
func (service *Service) StartHealthServer(bind string, port int) (*HealthServer, error) {
|
||||
return service.ServeHTTPHealth(bind, port)
|
||||
}
|
||||
|
||||
func (server *HealthServer) Close() error {
|
||||
if server == nil {
|
||||
return nil
|
||||
|
|
|
|||
21
serve.go
21
serve.go
|
|
@ -270,6 +270,20 @@ func (service *Service) Serve(bind string, port int) (*DNSServer, error) {
|
|||
return dnsServer, nil
|
||||
}
|
||||
|
||||
// StartDNSServer is an explicit convenience wrapper around Serve.
|
||||
//
|
||||
// dnsServer, err := service.StartDNSServer("127.0.0.1", 53)
|
||||
func (service *Service) StartDNSServer(bind string, port int) (*DNSServer, error) {
|
||||
return service.Serve(bind, port)
|
||||
}
|
||||
|
||||
// StartDNSAndHealth is an explicit convenience wrapper around ServeAll.
|
||||
//
|
||||
// runtime, err := service.StartDNSAndHealth("127.0.0.1", 53, 5554)
|
||||
func (service *Service) StartDNSAndHealth(bind string, dnsPort int, healthPort int) (*ServiceRuntime, error) {
|
||||
return service.ServeAll(bind, dnsPort, healthPort)
|
||||
}
|
||||
|
||||
// ServeAll starts DNS and health together.
|
||||
//
|
||||
// runtime, err := service.ServeAll("127.0.0.1", 53, 5554)
|
||||
|
|
@ -318,6 +332,13 @@ func (service *Service) ServeConfigured(bind string) (*ServiceRuntime, error) {
|
|||
return service.ServeAll(bind, service.dnsPort, service.httpPort)
|
||||
}
|
||||
|
||||
// StartConfigured is an explicit convenience wrapper around ServeConfigured.
|
||||
//
|
||||
// runtime, err := service.StartConfigured("127.0.0.1")
|
||||
func (service *Service) StartConfigured(bind string) (*ServiceRuntime, error) {
|
||||
return service.ServeConfigured(bind)
|
||||
}
|
||||
|
||||
type dnsRequestHandler struct {
|
||||
service *Service
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue