diff options
author | Valery Piashchynski <[email protected]> | 2022-03-06 12:35:14 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2022-03-06 12:35:14 +0100 |
commit | 1c5a6a590832bbefb2cab99a81f413a5a0e756de (patch) | |
tree | cc6595214e4ff39600099fb8c6f39e7a3dd560e9 /internal/rpc/client.go | |
parent | 587702be62b65c151d27dc79e62fcbbd11290e6f (diff) | |
parent | 70e4f020afd0352dc52114651f0f65c1965ed399 (diff) |
[#1036]: chore(cli): remove config plugin from the `root.go`
Diffstat (limited to 'internal/rpc/client.go')
-rw-r--r-- | internal/rpc/client.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/internal/rpc/client.go b/internal/rpc/client.go index 4e58972b..7d945add 100644 --- a/internal/rpc/client.go +++ b/internal/rpc/client.go @@ -1,24 +1,34 @@ -// Package prc contains wrapper around RPC client ONLY for internal usage. +// Package rpc contains wrapper around RPC client ONLY for internal usage. package rpc import ( "net/rpc" - "github.com/roadrunner-server/config/v2" "github.com/roadrunner-server/errors" goridgeRpc "github.com/roadrunner-server/goridge/v3/pkg/rpc" rpcPlugin "github.com/roadrunner-server/rpc/v2" + "github.com/spf13/viper" ) // NewClient creates client ONLY for internal usage (communication between our application with RR side). // Client will be connected to the RPC. -func NewClient(cfgPlugin *config.Plugin) (*rpc.Client, error) { - if !cfgPlugin.Has(rpcPlugin.PluginName) { +func NewClient(cfg string) (*rpc.Client, error) { + v := viper.New() + v.SetConfigFile(cfg) + + err := v.ReadInConfig() + if err != nil { + return nil, err + } + + if !v.IsSet(rpcPlugin.PluginName) { return nil, errors.E("rpc service disabled") } rpcConfig := &rpcPlugin.Config{} - if err := cfgPlugin.UnmarshalKey(rpcPlugin.PluginName, rpcConfig); err != nil { + + err = v.UnmarshalKey(rpcPlugin.PluginName, rpcConfig) + if err != nil { return nil, err } |