Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache connections #41

Closed
pmeinhardt opened this issue May 4, 2017 · 1 comment
Closed

Cache connections #41

pmeinhardt opened this issue May 4, 2017 · 1 comment

Comments

@pmeinhardt
Copy link
Contributor

As outlined in #3, it may be useful to cache connections for SSHKit.Contexts so subsequent commands do not have to set up a new one each time.

Open questions/things to do:

  • How do we cache connections?
    • should be a KV-store erlang process
    • probably store connections by {hostname, port, username} as the key?
    • commands always go to this process to fetch a connection
      • if a connection with the same key doesn't exist yet, create, cache and return it
      • else: return the cached connection unless it timed-out
    • so it's more of a "connection provider" than just a "cache"
  • How do we reuse the cached connections?
    • do we pass them in to the SSHKit.run and .upload functions?
    • do these methods access the (global) cache process?

Thoughts:

  • use GenServer for the connection provider
  • could be set as part of the context, but have a default value so you do not need to explicitly pass it when just using the DSL
context = SSHKit.context(hosts, provider: SSHKit.ConnectionProvider.new)

# in SSHKit

  def context(hosts, options \\ [provider: SSHit.ConnectionProvider.default])end

  def run(context, command) do
    # fetch connections from the context's connection provider
    # execute
  end
@pmeinhardt
Copy link
Contributor Author

Closing this. I think that making the connection explicit to enable re-use is a better next goal (see first draft in #138). Once that's achieved, connection caching could be implemented on top/outside of SSHKit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants