Files
paralus/proto/rpc/scheduler/internal.go
Nirav Parikh 0cd2a35ab5 expose cluster status update rpc (#296)
* expose cluster status update rpc

Signed-off-by: Nirav Parikh <nir.parikh05@gmail.com>

* added cluster rpc to relay peering rpc server listener

Signed-off-by: Nirav Parikh <nir.parikh05@gmail.com>

---------

Signed-off-by: Nirav Parikh <nir.parikh05@gmail.com>
2024-02-28 10:41:10 +05:30

58 lines
1.1 KiB
Go

package rpcv3
import (
"context"
"github.com/paralus/paralus/pkg/pool"
grpcpool "github.com/processout/grpc-go-pool"
)
// ClusterClient is the interface for accessing all the RPCs
// exposed by Cluster service
type ClusterClient interface {
Unhealthy()
Close() error
ClusterServiceClient
}
type clusterClient struct {
*grpcpool.ClientConn
*clusterServiceClient
}
var _ ClusterClient = (*clusterClient)(nil)
// ClusterPool maintains pool of grpc connections to cluster service
type ClusterPool interface {
Close()
NewClient(ctx context.Context) (ClusterClient, error)
}
// NewClusterPool new cluster pool
func NewClusterPool(addr string, maxConn int) ClusterPool {
return &clusterPool{
GRPCPool: pool.NewGRPCPool(addr, maxConn, nil),
}
}
type clusterPool struct {
*pool.GRPCPool
}
func (p *clusterPool) Close() {
if p.GRPCPool != nil {
p.GRPCPool.Close()
}
}
func (p *clusterPool) NewClient(ctx context.Context) (ClusterClient, error) {
cc, err := p.GetConnection(ctx)
if err != nil {
return nil, err
}
return &clusterClient{
cc,
&clusterServiceClient{cc.ClientConn},
}, nil
}