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

Refactoring...still thinking #245

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion internal/controller/api/connection_mediator_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (this *ConnectionMediatorV2) handleSendMessage() http.HandlerFunc {
return
}

client, err := this.proxyFactory.CreateProxy(req.Context(), clientState.OrgID, clientState.Account, clientState.ClientID, clientState.CanonicalFacts, clientState.Dispatchers, clientState.Tags)
client, err := this.proxyFactory.CreateProxy(req.Context(), clientState)
if err != nil {
logging.LogWithError(logger, "Unable to create proxy for connection", err)
writeConnectionFailureResponse(logger, w)
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/api/message_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
type MockClientProxyFactory struct {
}

func (MockClientProxyFactory) CreateProxy(context.Context, domain.OrgID, domain.AccountID, domain.ClientID, domain.CanonicalFacts, domain.Dispatchers, domain.Tags) (controller.ConnectorClient, error) {
func (MockClientProxyFactory) CreateProxy(context.Context, domain.ConnectorClientState) (controller.ConnectorClient, error) {
return MockClient{}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/controller/api/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func createConnectorClientProxy(ctx context.Context, log *logrus.Entry, tenantTr
return nil, err
}

proxy, err := proxyFactory.CreateProxy(ctx, clientState.OrgID, clientState.Account, clientState.ClientID, clientState.CanonicalFacts, clientState.Dispatchers, clientState.Tags)
proxy, err := proxyFactory.CreateProxy(ctx, clientState)
if err != nil {
log.WithFields(logrus.Fields{"error": err}).Errorf("Unable to create proxy for connection (%s:%s)", resolvedOrgId, clientId)
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ type ConnectorClient interface {
}

type ConnectorClientProxyFactory interface {
CreateProxy(context.Context, domain.OrgID, domain.AccountID, domain.ClientID, domain.CanonicalFacts, domain.Dispatchers, domain.Tags) (ConnectorClient, error)
CreateProxy(context.Context, domain.ConnectorClientState) (ConnectorClient, error)
}
16 changes: 8 additions & 8 deletions internal/mqtt/connector_client_proxy_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ func NewConnectorClientMQTTProxyFactory(cfg *config.Config, mqttClient MQTT.Clie
return &proxyFactory, nil
}

func (ccpf *ConnectorClientMQTTProxyFactory) CreateProxy(ctx context.Context, orgID domain.OrgID, account domain.AccountID, client_id domain.ClientID, canonicalFacts domain.CanonicalFacts, dispatchers domain.Dispatchers, tags domain.Tags) (controller.ConnectorClient, error) {
func (ccpf *ConnectorClientMQTTProxyFactory) CreateProxy(ctx context.Context, clientState domain.ConnectorClientState) (controller.ConnectorClient, error) {

logger := logger.Log.WithFields(logrus.Fields{"org_id": orgID, "account": account, "client_id": client_id})
logger := logger.Log.WithFields(logrus.Fields{"org_id": clientState.OrgID, "account": clientState.Account, "client_id": clientState.ClientID})

proxy := ConnectorClientMQTTProxy{
Logger: logger,
Config: ccpf.config,
OrgID: orgID,
AccountID: account,
ClientID: client_id,
OrgID: clientState.OrgID,
AccountID: clientState.Account,
ClientID: clientState.ClientID,
Client: ccpf.mqttClient,
TopicBuilder: ccpf.topicBuilder,
CanonicalFacts: canonicalFacts,
Dispatchers: dispatchers,
Tags: tags,
CanonicalFacts: clientState.CanonicalFacts,
Dispatchers: clientState.Dispatchers,
Tags: clientState.Tags,
}

return &proxy, nil
Expand Down
Loading