summaryrefslogtreecommitdiff
path: root/cmd/util/rpc.go
blob: 8ff6720aa1b5b07fe2bca951daccd27fbd0298ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package util

import (
	"errors"
	"github.com/spiral/roadrunner/service"
	rrpc "github.com/spiral/roadrunner/service/rpc"
	"net/rpc"
)

// RPCClient returns RPC client associated with given rr service container.
func RPCClient(container service.Container) (*rpc.Client, error) {
	svc, st := container.Get(rrpc.ID)
	if st < service.StatusOK {
		return nil, errors.New("RPC service is not configured")
	}

	return svc.(*rrpc.Service).Client()
}