session

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package session opens a datasource, raising an SSH tunnel first when the configuration calls for one.

It exists so that "connect to this datasource" is one step for every caller, and so the tunnel's lifetime is tied to the connection's rather than left to each command to remember.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Auth            []ssh.AuthMethod
	HostKeyCallback ssh.HostKeyCallback
}

Options override how the bastion is authenticated and verified.

Both default to the real thing — ssh-agent and ~/.ssh/known_hosts — and exist as fields so tests can drive the same Open path against an in-process SSH server.

type Session

type Session struct {
	Conn *db.Conn
	// contains filtered or unexported fields
}

Session is a database connection plus the tunnel carrying it, if any.

func Open

func Open(ctx context.Context, ds *config.DataSource, password string) (*Session, error)

Open connects to ds, dialling through its bastion when one is configured.

func OpenWith

func OpenWith(ctx context.Context, ds *config.DataSource, password string, opt Options) (*Session, error)

OpenWith is Open with explicit SSH credentials.

func (*Session) Close

func (s *Session) Close() error

Close releases the connection and then the tunnel underneath it.

func (*Session) TunnelErr

func (s *Session) TunnelErr() error

TunnelErr reports a forwarding failure that happened after connecting, which is how a bastion dropping mid-session becomes visible.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL