Documentation ¶
Index ¶
- Variables
- func Register(name string, opener Opener, opts ...RegisterOption)
- type Client
- type OpenOption
- type Opener
- type OpenerFunc
- type RegisterOption
- func RegisterCodec(m schemahcl.Marshaler, e schemahcl.Evaluator) RegisterOption
- func RegisterDriverOpener(open func(schema.ExecQuerier) (migrate.Driver, error)) RegisterOption
- func RegisterFlavours(flavours ...string) RegisterOption
- func RegisterTxOpener(open TxOpener) RegisterOption
- func RegisterURLParser(p URLParser) RegisterOption
- type SchemaChanger
- type Tx
- type TxClient
- type TxOpener
- type URL
- type URLParser
- type URLParserFunc
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupported = errors.New("sql/sqlclient: driver does not support changing connected schema")
ErrUnsupported is returned if a registered driver does not support changing the schema.
Functions ¶
func Register ¶
func Register(name string, opener Opener, opts ...RegisterOption)
Register registers a client Opener (i.e. creator) with the given name.
Types ¶
type Client ¶
type Client struct { // Name used when creating the client. Name string // DB used for creating the client. DB *sql.DB // URL holds an enriched url.URL. URL *URL // A migration driver for the attached dialect. migrate.Driver // Marshal and Evaluator functions for decoding // and encoding the schema documents. schemahcl.Marshaler schemahcl.Evaluator // contains filtered or unexported fields }
Client provides the common functionalities for working with Atlas from different applications (e.g. CLI and TF). Note, the Client is dialect specific and should be instantiated using a call to Open.
func (*Client) AddClosers ¶
AddClosers adds list of closers to close at the end of the client lifetime.
type OpenOption ¶ added in v0.4.2
type OpenOption func(*openOptions) error
OpenOption allows to configure a openOptions using functional arguments.
func OpenSchema ¶ added in v0.4.2
func OpenSchema(s string) OpenOption
OpenSchema opens the connection to the given schema. If the registered driver does not support this, ErrUnsupported is returned instead.
type Opener ¶
Opener opens a migration driver by the given URL.
func DriverOpener ¶
DriverOpener is a helper Opener creator for sharing between all drivers.
type OpenerFunc ¶
OpenerFunc allows using a function as an Opener.
type RegisterOption ¶
type RegisterOption func(*registerOptions)
RegisterOption allows configuring the Opener registration using functional options.
func RegisterCodec ¶
func RegisterCodec(m schemahcl.Marshaler, e schemahcl.Evaluator) RegisterOption
RegisterCodec registers static codec for attaching into the client after it is opened.
func RegisterDriverOpener ¶ added in v0.4.2
func RegisterDriverOpener(open func(schema.ExecQuerier) (migrate.Driver, error)) RegisterOption
RegisterDriverOpener registers a func to create a migrate.Driver from a schema.ExecQuerier. Registering this function is implicitly done when using DriverOpener. The passed opener is used when creating a TxClient.
func RegisterFlavours ¶
func RegisterFlavours(flavours ...string) RegisterOption
RegisterFlavours allows registering additional flavours (i.e. names), accepted by Atlas to open clients.
func RegisterTxOpener ¶ added in v0.7.1
func RegisterTxOpener(open TxOpener) RegisterOption
RegisterTxOpener allows registering a custom transaction opener with an optional close function.
func RegisterURLParser ¶
func RegisterURLParser(p URLParser) RegisterOption
RegisterURLParser allows registering a function for parsing the url.URL and attach additional info to the extended URL.
type SchemaChanger ¶ added in v0.4.2
SchemaChanger is implemented by a driver if it how to change the connection URL to represent another schema.
type Tx ¶ added in v0.7.1
type Tx struct { *sql.Tx CommitFn func() error // override default commit behavior RollbackFn func() error // override default rollback behavior }
Tx wraps sql.Tx with optional custom Commit and Rollback functions.
type TxClient ¶ added in v0.4.2
TxClient is returned by calling Client.Tx. It behaves the same as Client, but wraps all operations within a transaction.
type URL ¶
type URL struct { *url.URL // The DSN used for opening the connection. DSN string `json:"-"` // The Schema this client is connected to. Schema string }
URL extends the standard url.URL with additional connection information attached by the Opener (if any).