Skip to content

Commit

Permalink
Add public client to bootstrap params and remove from ringpop (cadenc…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjdawson2016 authored Apr 13, 2019
1 parent d5d74d9 commit 6f3a9ba
Show file tree
Hide file tree
Showing 24 changed files with 73 additions and 2,810 deletions.
13 changes: 0 additions & 13 deletions client/clientBean.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"github.com/uber/cadence/client/frontend"
"github.com/uber/cadence/client/history"
"github.com/uber/cadence/client/matching"
"github.com/uber/cadence/client/public"
"github.com/uber/cadence/common/cluster"
)

Expand All @@ -46,7 +45,6 @@ type (
GetHistoryClient() history.Client
GetMatchingClient() matching.Client
GetFrontendClient() frontend.Client
GetPublicClient() public.Client
GetRemoteAdminClient(cluster string) admin.Client
GetRemoteFrontendClient(cluster string) frontend.Client
}
Expand All @@ -60,7 +58,6 @@ type (
historyClient history.Client
matchingClient matching.Client
frontendClient frontend.Client
publicClient public.Client
remoteAdminClients map[string]admin.Client
remoteFrontendClients map[string]frontend.Client
}
Expand All @@ -87,11 +84,6 @@ func NewClientBean(factory Factory, dispatcherProvider DispatcherProvider, clust
return nil, err
}

publicClient, err := factory.NewPublicClient()
if err != nil {
return nil, err
}

remoteAdminClients := map[string]admin.Client{}
remoteFrontendClients := map[string]frontend.Client{}
for cluster, address := range clusterMetadata.GetAllClientAddress() {
Expand Down Expand Up @@ -127,7 +119,6 @@ func NewClientBean(factory Factory, dispatcherProvider DispatcherProvider, clust
historyClient: historyClient,
matchingClient: matchingClient,
frontendClient: frontendClient,
publicClient: publicClient,
remoteAdminClients: remoteAdminClients,
remoteFrontendClients: remoteFrontendClients,
}, nil
Expand All @@ -145,10 +136,6 @@ func (h *clientBeanImpl) GetFrontendClient() frontend.Client {
return h.frontendClient
}

func (h *clientBeanImpl) GetPublicClient() public.Client {
return h.publicClient
}

func (h *clientBeanImpl) GetRemoteAdminClient(cluster string) admin.Client {
client, ok := h.remoteAdminClients[cluster]
if !ok {
Expand Down
17 changes: 0 additions & 17 deletions client/clientBean_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/uber/cadence/client/frontend"
"github.com/uber/cadence/client/history"
"github.com/uber/cadence/client/matching"
"github.com/uber/cadence/client/public"
)

// MockClientBean is an autogenerated mock type for the MockClientBean type
Expand Down Expand Up @@ -84,22 +83,6 @@ func (_m *MockClientBean) GetFrontendClient() frontend.Client {
return r0
}

// GetPublicClient provides a mock function with given fields:
func (_m *MockClientBean) GetPublicClient() public.Client {
ret := _m.Called()

var r0 public.Client
if rf, ok := ret.Get(0).(func() public.Client); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(public.Client)
}
}

return r0
}

// GetRemoteAdminClient provides a mock function with given fields: _a0
func (_m *MockClientBean) GetRemoteAdminClient(_a0 string) admin.Client {
ret := _m.Called(_a0)
Expand Down
40 changes: 0 additions & 40 deletions client/clientfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ import (
"github.com/uber/cadence/client/frontend"
"github.com/uber/cadence/client/history"
"github.com/uber/cadence/client/matching"
"github.com/uber/cadence/client/public"
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/membership"
"github.com/uber/cadence/common/metrics"
publicClientInterface "go.uber.org/cadence/.gen/go/cadence/workflowserviceclient"
)

const (
Expand All @@ -57,12 +55,10 @@ type Factory interface {
NewHistoryClient() (history.Client, error)
NewMatchingClient() (matching.Client, error)
NewFrontendClient() (frontend.Client, error)
NewPublicClient() (public.Client, error)

NewHistoryClientWithTimeout(timeout time.Duration) (history.Client, error)
NewMatchingClientWithTimeout(timeout time.Duration, longPollTimeout time.Duration) (matching.Client, error)
NewFrontendClientWithTimeout(timeout time.Duration, longPollTimeout time.Duration) (frontend.Client, error)
NewPublicClientWithTimeout(timeout time.Duration, longPollTimeout time.Duration) (public.Client, error)

NewAdminClientWithTimeoutAndDispatcher(rpcName string, timeout time.Duration, dispatcher *yarpc.Dispatcher) (admin.Client, error)
NewFrontendClientWithTimeoutAndDispatcher(rpcName string, timeout time.Duration, longPollTimeout time.Duration, dispatcher *yarpc.Dispatcher) (frontend.Client, error)
Expand Down Expand Up @@ -98,10 +94,6 @@ func (cf *rpcClientFactory) NewFrontendClient() (frontend.Client, error) {
return cf.NewFrontendClientWithTimeout(frontend.DefaultTimeout, frontend.DefaultLongPollTimeout)
}

func (cf *rpcClientFactory) NewPublicClient() (public.Client, error) {
return cf.NewPublicClientWithTimeout(public.DefaultTimeout, public.DefaultLongPollTimeout)
}

func (cf *rpcClientFactory) NewHistoryClientWithTimeout(timeout time.Duration) (history.Client, error) {
resolver, err := cf.monitor.GetResolver(common.HistoryServiceName)
if err != nil {
Expand Down Expand Up @@ -188,38 +180,6 @@ func (cf *rpcClientFactory) NewFrontendClientWithTimeout(
return client, nil
}

func (cf *rpcClientFactory) NewPublicClientWithTimeout(
timeout time.Duration,
longPollTimeout time.Duration,
) (public.Client, error) {

// public client and frontend client are essentially the same,
// except the interface definition
resolver, err := cf.monitor.GetResolver(common.FrontendServiceName)
if err != nil {
return nil, err
}

keyResolver := func(key string) (string, error) {
host, err := resolver.Lookup(key)
if err != nil {
return "", err
}
return host.GetAddress(), nil
}

clientProvider := func(clientKey string) (interface{}, error) {
dispatcher := cf.rpcFactory.CreateDispatcherForOutbound(publicCaller, common.FrontendServiceName, clientKey)
return publicClientInterface.New(dispatcher.ClientConfig(common.FrontendServiceName)), nil
}

client := public.NewClient(timeout, longPollTimeout, common.NewClientCache(keyResolver, clientProvider))
if cf.metricsClient != nil {
client = public.NewMetricClient(client, cf.metricsClient)
}
return client, nil
}

func (cf *rpcClientFactory) NewAdminClientWithTimeoutAndDispatcher(
rpcName string,
timeout time.Duration,
Expand Down
Loading

0 comments on commit 6f3a9ba

Please sign in to comment.