func (r *relay) Client() client.Client {
	return r.client
}
Client returns the relays Client interface.
package relay
import (
	"fmt"
	"os"
	"sync"
	"github.com/intel/cri-resource-manager/pkg/cri/client"
	"github.com/intel/cri-resource-manager/pkg/cri/server"
	logger "github.com/intel/cri-resource-manager/pkg/log"
)
const (
	DisableService = client.DontConnect
)
type Options struct {
	RelaySocket string
	ImageSocket string
	RuntimeSocket string
	QualifyReqFn func(interface{}) string
}
type Relay interface {
	Setup() error
	Start() error
	Stop()
	Client() client.Client
	Server() server.Server
}
type relay struct {
	logger.Logger
	sync.Mutex                
	options    Options        
	client     client.Client  
	server     server.Server  
}
func NewRelay(options Options) (Relay, error) {
	var err error
	r := &relay{
		Logger:  logger.NewLogger("cri/relay"),
		options: options,
	}
	cltopts := client.Options{
		ImageSocket:   r.options.ImageSocket,
		RuntimeSocket: r.options.RuntimeSocket,
		DialNotify:    r.dialNotify,
	}
	if r.client, err = client.NewClient(cltopts); err != nil {
		return nil, relayError("failed to create relay client: %v", err)
	}
	srvopts := server.Options{
		Socket:       r.options.RelaySocket,
		User:         -1,
		Group:        -1,
		Mode:         0660,
		QualifyReqFn: r.options.QualifyReqFn,
	}
	if r.server, err = server.NewServer(srvopts); err != nil {
		return nil, relayError("failed to create relay server: %v", err)
	}
	return r, nil
}
func (r *relay) Setup() error {
	if err := r.client.Connect(client.ConnectOptions{Wait: true}); err != nil {
		return relayError("client connection failed: %v", err)
	}
	if r.options.ImageSocket != DisableService {
		if err := r.server.RegisterImageService(r); err != nil {
			return relayError("failed to register image service: %v", err)
		}
	}
	if r.options.RuntimeSocket != DisableService {
		if err := r.server.RegisterRuntimeService(r); err != nil {
			return relayError("failed to register runtime service: %v", err)
		}
	}
	return nil
}
func (r *relay) Start() error {
	if err := r.server.Start(); err != nil {
		return relayError("failed to start relay: %v", err)
	}
	return nil
}
func (r *relay) Stop() {
	r.client.Close()
	r.server.Stop()
}