datasource

package
v0.10.8 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDatasourceID

func GetDatasourceID(ctx context.Context) int64

Types

type AWSDatasource

type AWSDatasource struct {
	// contains filtered or unexported fields
}

AWSDatasource stores a cache of several instances. Each Map will depend on the datasource ID (and connection options):

  • config: Base configuration. It will be used as base to populate datasource settings. It does not depend on connection options (only one per datasource)
  • api: API instace with the common methods to contact the data source API.
  • driver: Abstraction on top the upstream sql.Driver. Defined to handle multiple connections.
  • db: Upstream database (sql.DB).
  • sessionCache: AWS cache. This is not a Map since it does not depend on the datasource.

func New

func New() *AWSDatasource

func (*AWSDatasource) GetAPI

func (s *AWSDatasource) GetAPI(
	id int64,
	options sqlds.Options,
	settingsLoader models.Loader,
	apiLoader api.Loader,
) (api.AWSAPI, error)

GetAPI returns an API interface. When called multiple times with the same id and options, it will return a cached version of the API. The first time, it will use the loader functions to initialize the required settings and API.

func (*AWSDatasource) GetDB

func (s *AWSDatasource) GetDB(
	id int64,
	options sqlds.Options,
	settingsLoader models.Loader,
	apiLoader api.Loader,
	driverLoader driver.Loader,
) (*sql.DB, error)

GetDB returns a *sql.DB. It will use the loader functions to initialize the required settings, API and driver and finally create a DB.

func (*AWSDatasource) Init

Init stores the data source configuration. It's needed for the GetDB and GetAPI functions

Jump to

Keyboard shortcuts

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