Open andig opened 1 year ago
Sure, but I probably won't make it this week.
Put up a second PR as alternative. Much smaller api surface- kinda like that one ;)
@frzifus friendly ping. Could I get your review on https://github.com/grid-x/modbus/pull/70? #59 may be "cleaner" but is much more invasive. #70 is sweet and short.
i have put it on my to-do list. but i can't promise anything in the next 14 days - Iam sorry.
Currently, packers and transporters are closely coupled in the
New*ClientHandler
. This creates problems when sharing a single physical connection (part of the transporter) amongst multiple clients where each client talks to a different slave id (part of the packager). The current api make it impossible to implement race-free concurrent access.While packager and transporter already have distinct purposes, the respective types cannot be created individually from outside the library as the types are not public. Using
NewClient2
is cumbersome as the required packager/transporter types both need be created taking an address as parameter which is pointless for a packager.This PR makes the packager/transporter types public and hence allows re-using the transporter while creating immutable packagers per slave id.
/cc @frzifus @gq0 @hsteidl could I kindly ask you to take a look at the attached PR? It is not finished but clearly demonstrates the approach. It exposes quite a bit of additional (though not su useful) api with the packager and transporter types. Maybe we can come up with a more trimmed approach, I'd be happy to update the PR with any suggestions.
Note: I like the approach from https://github.com/grid-x/modbus/pull/70 much more as it is much less invasive and introduces very little additional api.