hashicorp / go-plugin

Golang plugin system over RPC.
Mozilla Public License 2.0
5.25k stars 450 forks source link

Feature Request: Be able to provide custom `yamux.Config` to `NewRPCClient` #248

Open mickmister opened 1 year ago

mickmister commented 1 year ago

In order to use a debugger while developing a plugin, I need to modify the below code to allow for the RPC connection's timeout to tolerate the amount of time the debugger is paused. Before making this change, the plugin gets disconnected due to the failing timeout.

https://github.com/hashicorp/go-plugin/blob/e889c1ba1044d1b183d4ed45d0f2f531db3ba50b/rpc_client.go#L64-L66

func NewRPCClient(conn io.ReadWriteCloser, plugins map[string]Plugin) (*RPCClient, error) { 
    sessionConfig := yamux.DefaultConfig()
    sessionConfig.EnableKeepAlive = true
    sessionConfig.ConnectionWriteTimeout = time.Minute * 5

    // Create the yamux client so we can multiplex 
    mux, err := yamux.Client(conn, sessionConfig)

I'd like to be able to provide a value to this function, in order to allow for customizing the yamux.Config used here. I'd like to make the change to make this configurable, possibly by environment variables if that's the most appropriate way. Any advice on how this change should be done?

mickmister commented 6 months ago

Does anyone mind if I try to implement this?