add unix domain socket support for api & metrics services

This commit is contained in:
ginuerzh
2024-11-22 22:49:10 +08:00
parent 6f001a779a
commit c1e6164a83
2 changed files with 10 additions and 4 deletions
+5 -2
View File
@@ -53,8 +53,11 @@ type server struct {
cclose chan struct{}
}
func NewService(addr string, opts ...Option) (service.Service, error) {
ln, err := net.Listen("tcp", addr)
func NewService(network, addr string, opts ...Option) (service.Service, error) {
if network == "" {
network = "tcp"
}
ln, err := net.Listen(network, addr)
if err != nil {
return nil, err
}