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

import (
	"errors"
	"net/rpc"

	"github.com/spiral/roadrunner/service"
	rrpc "github.com/spiral/roadrunner/service/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()
}