Open andig opened 1 year ago
Friendly ping @frzifus. This would be really helpful using the module downstream and cross-goroutines. The diff looks bigger than it is as I've moved the ...Client routines above the respective ...Handlers for clarity.
Any chance for feedback on this change?
Friendly ping. This PR is needed to make a modbus connection usable from multiple goroutines, one per id.
ping @frzifus did you get a chance to review?
ping @frzifus any chance to take a look? Imho this really is a smallish change, although the diff looks large.
Since users may initialized handlers without the new... functions, I would consider it to mark it as breaking change. wdyt?
That's a good point. Not doing so will be obvious due to nil pointer panics, but it's definitely breaking. Since this is the case, I'd be happy to add a more fluent way of passing parameters, too if that would help to move this PR along.
If anybody wants to test this, I've created a fork at https://github.com/evcc-io/modbus. Happy to update this PR if interest arises.
Fix https://github.com/grid-x/modbus/issues/56
This is an alternative approach. It features much smaller api surface but leaves responsibility up to the user to understand the transporter's shared nature.
Note: decide name. Is
Clone()
sufficiently clear? MaybeShare()
orShareConnection()
or maybeWithPackager
?