eclipse-uprotocol / eclipse-uprotocol/up-transport-mqtt5-java
Remove the MQTT Client dependency from the factory
- Dominant language
- Java
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
The current design requires you to create a MQTT client implementation specific object outside of the factory and then inject it into the factory for a specific type which makes the factory methods specific and requires the clients to work with and depend on the specific MQTT5 client implementation, see example code below:
````
Mqtt5Client mockedClient = mock(Mqtt5Client.class);
var result = TransportFactory.createInstance(mock(UUri.class), mockedClient);
````
It is Ok that up-transport-mqtt5-java could support multiple client implementations other than HiveMQ (ex. paho) however the factory method should be generic such that we simply state what type we want to createInstance() of and/or also provide a default that returns a default instance of a client. In order to do this, we need to generalize the configuration options passed to MQTT5 clients in a configuration file starting with username + password but then eventually support passing certificates once we test the client for a given broker like Azure.
then the API would be something like:
````
// Generalized MQTT configuration like username & password
MqttConfig config;
// uE source address
UUri source;
UTransport transport = Mqtt5TransportFactory.createInstance(source, config);
````
Contributor guide
Research direction
Start with the current TransportFactory API and compare it with the proposed Mqtt5TransportFactory.createInstance(source, config) usage. Define what generalized MQTT configuration must cover beyond username and password, and consider the issue complete when factory callers no longer inject a specific MQTT5 client implementation while the requested transport can still be created.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- networking
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100