Closed taylortrimble closed 1 year ago
What is an example of using a custom function? Say for #32 Nagel's algorithm.
I like the direction. Though I'm curious about the alternatives:
I'd like to come up with a cleaner way to do gatewayParts before making this something people may need to write.
Hi all,
I've shared these ideas with @bdotdub and gone over parts with @nathany now as well. I just found my notes and figured I'd type them here on GitHub as well.
The ideas I will lay out below was guided by some factors from the community:
Here's what I came up with:
The current
Connection
struct inmaster
is simply anet.Conn
wrapper with some configuration. This isn't the same as a mockable interface, and is probably insufficient. Indevelop
,Connection
handles three things:io.ReadWriteCloser
)I posit that if we move the responsibility for reconnection into the
Client
, we can get rid of theConnection
altogether and simply useio.ReadWriteCloser
. It would work this way:Client
detects a connection (io.ReadWriteCloser
) has gone sour, it gets a new one from a provider functiontls.Certificate
Example
With this scheme, the Client is able to make a new connection whenever it needs one. The user is able to replace
NewConnection
to provide a custom-configured connection, as well as replaceNewConnection
to provide a mock connection.DefaultConnectionProvider
is exported so it can be used if the user wants override only a few settings from the default connection.Let me know what you guys think!