You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by Andrey Skorikov <an...@codecentric.de> on 2018/10/05 10:58:50 UTC

Provide Conection Metadata

Hello,

currently, in order to find out which capabilities a PlcConnection 
provides (reading, writing, subscription) we must invoke operations that 
return an Optional value (getReader() or readRequestBuilder()) and check 
if the value is not empty. These methods must also be called in order to 
actually perform the required operations (reading/writing/subscription).

I believe that these are two related but different concerns and should 
be separated. For example, when checking whether a PlcConnection 
supports reading we should not be required to actually obtain an 
instance of PlcReader/PlcReadRequest.Builder. Analogously, if we already 
know that a PlcConnection supports reading, we should not have to deal 
with an optional value when obtaining an instance of 
PlcReader/PlcReadRequest.Builder off it (and call .get() on it).

Therefore, I suggest that we provide a separate interface/operation for 
obtaining metaformation on PlcConnection (describing its capabilities) 
and make getReader()/readRequestBuilder() operations return a 
non-optional value (and throw an Exception when invoked on a 
PlcConnection that does not provide the required capability).

This would allow to check for capabilities independently from actually 
using them, for example in early initialization stages. Furthermore, 
this would also simplify the usage of the capabilities since we would 
not be required to deal with optional values at that stages anymore.

What do you think?

Best regards,
Andrey