diff options
Diffstat (limited to 'service/rpc/config.go')
-rw-r--r-- | service/rpc/config.go | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/service/rpc/config.go b/service/rpc/config.go index fc8cfdbb..8a29c2d8 100644 --- a/service/rpc/config.go +++ b/service/rpc/config.go @@ -3,9 +3,9 @@ package rpc import ( "errors" "github.com/spiral/roadrunner/service" + "github.com/spiral/roadrunner/util" "net" "strings" - "syscall" ) // Config defines RPC service config. @@ -37,7 +37,7 @@ func (c *Config) InitDefaults() error { // Valid returns nil if config is valid. func (c *Config) Valid() error { if dsn := strings.Split(c.Listen, "://"); len(dsn) != 2 { - return errors.New("invalid socket DSN (tcp://:6001, unix://rpc.sock)") + return errors.New("invalid socket DSN (tcp://:6001, unix://file.sock)") } return nil @@ -45,23 +45,14 @@ func (c *Config) Valid() error { // Listener creates new rpc socket Listener. func (c *Config) Listener() (net.Listener, error) { - dsn := strings.Split(c.Listen, "://") - if len(dsn) != 2 { - return nil, errors.New("invalid socket DSN (tcp://:6001, unix://rpc.sock)") - } - - if dsn[0] == "unix" { - syscall.Unlink(dsn[1]) - } - - return net.Listen(dsn[0], dsn[1]) + return util.CreateListener(c.Listen); } // Dialer creates rpc socket Dialer. func (c *Config) Dialer() (net.Conn, error) { dsn := strings.Split(c.Listen, "://") if len(dsn) != 2 { - return nil, errors.New("invalid socket DSN (tcp://:6001, unix://rpc.sock)") + return nil, errors.New("invalid socket DSN (tcp://:6001, unix://file.sock)") } return net.Dial(dsn[0], dsn[1]) |