Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove client interfaces #1301

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/admin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"go.temporal.io/server/common"
)

var _ Client = (*clientImpl)(nil)
var _ adminservice.AdminServiceClient = (*clientImpl)(nil)

const (
// DefaultTimeout is the default timeout used to make calls
Expand All @@ -55,7 +55,7 @@ func NewClient(
timeout time.Duration,
largeTimeout time.Duration,
clients common.ClientCache,
) Client {
) adminservice.AdminServiceClient {
return &clientImpl{
timeout: timeout,
largeTimeout: largeTimeout,
Expand Down
34 changes: 0 additions & 34 deletions client/admin/interface.go

This file was deleted.

8 changes: 4 additions & 4 deletions client/admin/metricClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ import (
"go.temporal.io/server/common/metrics"
)

var _ Client = (*metricClient)(nil)
var _ adminservice.AdminServiceClient = (*metricClient)(nil)

type metricClient struct {
client Client
client adminservice.AdminServiceClient
metricsClient metrics.Client
}

// NewMetricClient creates a new instance of Client that emits metrics
func NewMetricClient(client Client, metricsClient metrics.Client) Client {
// NewMetricClient creates a new instance of adminservice.AdminServiceClient that emits metrics
func NewMetricClient(client adminservice.AdminServiceClient, metricsClient metrics.Client) adminservice.AdminServiceClient {
return &metricClient{
client: client,
metricsClient: metricsClient,
Expand Down
8 changes: 4 additions & 4 deletions client/admin/retryableClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ import (
"go.temporal.io/server/common/backoff"
)

var _ Client = (*retryableClient)(nil)
var _ adminservice.AdminServiceClient = (*retryableClient)(nil)

type retryableClient struct {
client Client
client adminservice.AdminServiceClient
policy backoff.RetryPolicy
isRetryable backoff.IsRetryable
}

// NewRetryableClient creates a new instance of Client with retry policy
func NewRetryableClient(client Client, policy backoff.RetryPolicy, isRetryable backoff.IsRetryable) Client {
// NewRetryableClient creates a new instance of adminservice.AdminServiceClient with retry policy
func NewRetryableClient(client adminservice.AdminServiceClient, policy backoff.RetryPolicy, isRetryable backoff.IsRetryable) adminservice.AdminServiceClient {
return &retryableClient{
client: client,
policy: policy,
Expand Down
63 changes: 33 additions & 30 deletions client/clientBean.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,38 @@ import (
"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/client/history"
"go.temporal.io/server/client/matching"
"go.temporal.io/server/common/cluster"
)

type (
// Bean in an collection of clients
Bean interface {
GetHistoryClient() history.Client
SetHistoryClient(client history.Client)
GetMatchingClient(namespaceIDToName NamespaceIDToNameFunc) (matching.Client, error)
SetMatchingClient(client matching.Client)
GetFrontendClient() frontend.Client
SetFrontendClient(client frontend.Client)
GetRemoteAdminClient(cluster string) admin.Client
SetRemoteAdminClient(cluster string, client admin.Client)
GetRemoteFrontendClient(cluster string) frontend.Client
SetRemoteFrontendClient(cluster string, client frontend.Client)
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 history.Client
historyClient historyservice.HistoryServiceClient
matchingClient atomic.Value
remoteAdminClients map[string]admin.Client
remoteFrontendClients map[string]frontend.Client
remoteAdminClients map[string]adminservice.AdminServiceClient
remoteFrontendClients map[string]workflowservice.WorkflowServiceClient
factory Factory
}
)
Expand All @@ -72,8 +75,8 @@ func NewClientBean(factory Factory, clusterMetadata cluster.Metadata) (Bean, err
return nil, err
}

remoteAdminClients := map[string]admin.Client{}
remoteFrontendClients := map[string]frontend.Client{}
remoteAdminClients := map[string]adminservice.AdminServiceClient{}
remoteFrontendClients := map[string]workflowservice.WorkflowServiceClient{}

for clusterName, info := range clusterMetadata.GetAllClusterInfo() {
if !info.Enabled {
Expand Down Expand Up @@ -111,40 +114,40 @@ func NewClientBean(factory Factory, clusterMetadata cluster.Metadata) (Bean, err
}, nil
}

func (h *clientBeanImpl) GetHistoryClient() history.Client {
func (h *clientBeanImpl) GetHistoryClient() historyservice.HistoryServiceClient {
return h.historyClient
}

func (h *clientBeanImpl) SetHistoryClient(
client history.Client,
client historyservice.HistoryServiceClient,
) {
h.historyClient = client
}

func (h *clientBeanImpl) GetMatchingClient(namespaceIDToName NamespaceIDToNameFunc) (matching.Client, error) {
func (h *clientBeanImpl) GetMatchingClient(namespaceIDToName NamespaceIDToNameFunc) (matchingservice.MatchingServiceClient, error) {
if client := h.matchingClient.Load(); client != nil {
return client.(matching.Client), nil
return client.(matchingservice.MatchingServiceClient), nil
}
return h.lazyInitMatchingClient(namespaceIDToName)
}

func (h *clientBeanImpl) SetMatchingClient(
client matching.Client,
client matchingservice.MatchingServiceClient,
) {
h.matchingClient.Store(client)
}

func (h *clientBeanImpl) GetFrontendClient() frontend.Client {
func (h *clientBeanImpl) GetFrontendClient() workflowservice.WorkflowServiceClient {
return h.remoteFrontendClients[h.currentCluster]
}

func (h *clientBeanImpl) SetFrontendClient(
client frontend.Client,
client workflowservice.WorkflowServiceClient,
) {
h.remoteFrontendClients[h.currentCluster] = client
}

func (h *clientBeanImpl) GetRemoteAdminClient(cluster string) admin.Client {
func (h *clientBeanImpl) GetRemoteAdminClient(cluster string) adminservice.AdminServiceClient {
client, ok := h.remoteAdminClients[cluster]
if !ok {
panic(fmt.Sprintf(
Expand All @@ -158,12 +161,12 @@ func (h *clientBeanImpl) GetRemoteAdminClient(cluster string) admin.Client {

func (h *clientBeanImpl) SetRemoteAdminClient(
cluster string,
client admin.Client,
client adminservice.AdminServiceClient,
) {
h.remoteAdminClients[cluster] = client
}

func (h *clientBeanImpl) GetRemoteFrontendClient(cluster string) frontend.Client {
func (h *clientBeanImpl) GetRemoteFrontendClient(cluster string) workflowservice.WorkflowServiceClient {
client, ok := h.remoteFrontendClients[cluster]
if !ok {
panic(fmt.Sprintf(
Expand All @@ -177,16 +180,16 @@ func (h *clientBeanImpl) GetRemoteFrontendClient(cluster string) frontend.Client

func (h *clientBeanImpl) SetRemoteFrontendClient(
cluster string,
client frontend.Client,
client workflowservice.WorkflowServiceClient,
) {
h.remoteFrontendClients[cluster] = client
}

func (h *clientBeanImpl) lazyInitMatchingClient(namespaceIDToName NamespaceIDToNameFunc) (matching.Client, error) {
func (h *clientBeanImpl) lazyInitMatchingClient(namespaceIDToName NamespaceIDToNameFunc) (matchingservice.MatchingServiceClient, error) {
h.Lock()
defer h.Unlock()
if cached := h.matchingClient.Load(); cached != nil {
return cached.(matching.Client), nil
return cached.(matchingservice.MatchingServiceClient), nil
}
client, err := h.factory.NewMatchingClient(namespaceIDToName)
if err != nil {
Expand Down
38 changes: 19 additions & 19 deletions client/clientBean_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading