summaryrefslogtreecommitdiff
path: root/internal/rpc/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/rpc/client.go')
-rw-r--r--internal/rpc/client.go20
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
}