mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-30 02:28:16 +03:00
1d6d85cff4
Squashed commit of the following: commit586b0eb180
Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Nov 12 19:58:56 2024 +0300 next: upd more commitd729aa150f
Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Nov 12 16:53:15 2024 +0300 next/websvc: upd more commit0c64e6cfc6
Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Nov 11 21:08:51 2024 +0300 next: upd more commit05eec75222
Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Fri Nov 8 19:20:02 2024 +0300 next: upd code
36 lines
988 B
Go
36 lines
988 B
Go
// Package agh contains common entities and interfaces of AdGuard Home.
|
|
package agh
|
|
|
|
import (
|
|
"github.com/AdguardTeam/golibs/service"
|
|
)
|
|
|
|
// ServiceWithConfig is an extension of the [Service] interface for services
|
|
// that can return their configuration.
|
|
//
|
|
// TODO(a.garipov): Consider removing this generic interface if we figure out
|
|
// how to make it testable in a better way.
|
|
type ServiceWithConfig[ConfigType any] interface {
|
|
service.Interface
|
|
|
|
Config() (c ConfigType)
|
|
}
|
|
|
|
// type check
|
|
var _ ServiceWithConfig[struct{}] = (*EmptyServiceWithConfig[struct{}])(nil)
|
|
|
|
// EmptyServiceWithConfig is a ServiceWithConfig that does nothing. Its Config
|
|
// method returns Conf.
|
|
//
|
|
// TODO(a.garipov): Remove if unnecessary.
|
|
type EmptyServiceWithConfig[ConfigType any] struct {
|
|
service.Empty
|
|
|
|
Conf ConfigType
|
|
}
|
|
|
|
// Config implements the [ServiceWithConfig] interface for
|
|
// *EmptyServiceWithConfig.
|
|
func (s *EmptyServiceWithConfig[ConfigType]) Config() (conf ConfigType) {
|
|
return s.Conf
|
|
}
|