func NewClientBean(factory Factory, clusterMetadata cluster.Metadata) (Bean, error) {
	historyClient, err := factory.NewHistoryClient()
	if err != nil {
		return nil, err
	}
	remoteAdminClients := map[string]adminservice.AdminServiceClient{}
	remoteFrontendClients := map[string]workflowservice.WorkflowServiceClient{}
	for clusterName, info := range clusterMetadata.GetAllClusterInfo() {
		if !info.Enabled {
			continue
		}
		adminClient, err := factory.NewAdminClientWithTimeout(
			info.RPCAddress,
			admin.DefaultTimeout,
			admin.DefaultLargeTimeout,
		)
		if err != nil {
			return nil, err
		}
		remoteFrontendClient, err := factory.NewFrontendClientWithTimeout(
			info.RPCAddress,
			frontend.DefaultTimeout,
			frontend.DefaultLongPollTimeout,
		)
		if err != nil {
			return nil, err
		}
		remoteAdminClients[clusterName] = adminClient
		remoteFrontendClients[clusterName] = remoteFrontendClient
	}
	return &clientBeanImpl{
		currentCluster:        clusterMetadata.GetCurrentClusterName(),
		factory:               factory,
		historyClient:         historyClient,
		remoteAdminClients:    remoteAdminClients,
		remoteFrontendClients: remoteFrontendClients,
	}, nil
}
NewClientBean provides a collection of clients
package client
import (
	"fmt"
	"sync"
	"sync/atomic"
	"go.temporal.io/api/workflowservice/v1"
	"go.temporal.io/server/api/adminservice/v1"
	"go.temporal.io/server/api/historyservice/v1"
	"go.temporal.io/server/api/matchingservice/v1"
	"go.temporal.io/server/client/admin"
	"go.temporal.io/server/client/frontend"
	"go.temporal.io/server/common/cluster"
)
type (
	Bean interface {
		GetHistoryClient() historyservice.HistoryServiceClient
		SetHistoryClient(client historyservice.HistoryServiceClient)
		GetMatchingClient(namespaceIDToName NamespaceIDToNameFunc) (matchingservice.MatchingServiceClient, error)
		SetMatchingClient(client matchingservice.MatchingServiceClient)
		GetFrontendClient() workflowservice.WorkflowServiceClient
		SetFrontendClient(client workflowservice.WorkflowServiceClient)
		GetRemoteAdminClient(cluster string) adminservice.AdminServiceClient
		SetRemoteAdminClient(cluster string, client adminservice.AdminServiceClient)
		GetRemoteFrontendClient(cluster string) workflowservice.WorkflowServiceClient
		SetRemoteFrontendClient(cluster string, client workflowservice.WorkflowServiceClient)
	}
	clientBeanImpl struct {
		sync.Mutex
		currentCluster        string
		historyClient         historyservice.HistoryServiceClient
		matchingClient        atomic.Value
		remoteAdminClients    map[string]adminservice.AdminServiceClient
		remoteFrontendClients map[string]workflowservice.WorkflowServiceClient
		factory               Factory
	}
)