Skip to content

Cache connections #41

Closed
Closed
@pmeinhardt

Description

@pmeinhardt

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions