Documentation ¶
Index ¶
- func Named(name string, value any) sql.NamedArg
- type SqlConnectionString
- func (c *SqlConnectionString) ConnectionString() string
- func (c *SqlConnectionString) Parse(connectionString string) error
- func (c *SqlConnectionString) Valid() bool
- func (c *SqlConnectionString) WithDatabase(database string) *SqlConnectionString
- func (c *SqlConnectionString) WithPassword(password string) *SqlConnectionString
- func (c *SqlConnectionString) WithPort(port int) *SqlConnectionString
- func (c *SqlConnectionString) WithServer(serverName string) *SqlConnectionString
- func (c *SqlConnectionString) WithUser(username string) *SqlConnectionString
- type SqlDatabaseContext
- type SqlFactory
- type SqlMigrationsRepo
- type SqlService
- type SqlServiceOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SqlConnectionString ¶
type SqlConnectionString struct { Username string Password string Port int Server string Database string EnableTLS bool }
func (*SqlConnectionString) ConnectionString ¶
func (c *SqlConnectionString) ConnectionString() string
func (*SqlConnectionString) Parse ¶
func (c *SqlConnectionString) Parse(connectionString string) error
func (*SqlConnectionString) Valid ¶
func (c *SqlConnectionString) Valid() bool
func (*SqlConnectionString) WithDatabase ¶
func (c *SqlConnectionString) WithDatabase(database string) *SqlConnectionString
func (*SqlConnectionString) WithPassword ¶
func (c *SqlConnectionString) WithPassword(password string) *SqlConnectionString
func (*SqlConnectionString) WithPort ¶
func (c *SqlConnectionString) WithPort(port int) *SqlConnectionString
func (*SqlConnectionString) WithServer ¶
func (c *SqlConnectionString) WithServer(serverName string) *SqlConnectionString
func (*SqlConnectionString) WithUser ¶
func (c *SqlConnectionString) WithUser(username string) *SqlConnectionString
type SqlDatabaseContext ¶
type SqlDatabaseContext struct { ConnectionString *SqlConnectionString CurrentTable string }
func (*SqlDatabaseContext) CurrentDatabase ¶
func (s *SqlDatabaseContext) CurrentDatabase() string
type SqlFactory ¶
type SqlFactory struct { Context *execution_context.Context Database *sqlDatabase Timeout time.Duration DatabaseContext *SqlDatabaseContext Logger *log.Logger }
func NewFactory ¶
func NewFactory(connectionString string) *SqlFactory
func (*SqlFactory) Connect ¶
func (f *SqlFactory) Connect() *sqlDatabase
func (*SqlFactory) Ping ¶
func (f *SqlFactory) Ping() error
func (*SqlFactory) WithDatabase ¶
func (f *SqlFactory) WithDatabase(databaseName string) *SqlFactory
func (*SqlFactory) WithTimeout ¶
func (f *SqlFactory) WithTimeout(seconds int) *SqlFactory
type SqlMigrationsRepo ¶
type SqlMigrationsRepo struct {
// contains filtered or unexported fields
}
func NewSqlMigrationRepo ¶
func NewSqlMigrationRepo() *SqlMigrationsRepo
func (*SqlMigrationsRepo) CreateTable ¶
func (m *SqlMigrationsRepo) CreateTable() error
func (*SqlMigrationsRepo) GetAppliedMigrations ¶
func (m *SqlMigrationsRepo) GetAppliedMigrations() ([]migrations.MigrationEntity, error)
func (*SqlMigrationsRepo) SaveMigrationStatus ¶
func (m *SqlMigrationsRepo) SaveMigrationStatus(migration migrations.MigrationEntity) error
type SqlService ¶
type SqlService struct { ConnectionString string GlobalDatabaseName string TenantDatabaseName string // contains filtered or unexported fields }
SqlService structure
func Init ¶
func Init() *SqlService
Init initiates the SqlDb service and global database factory returns a SqlDbService pointer
func New ¶
func New() *SqlService
New Creates a Sql service using the default configuration This uses the environment variables to define the connection and the database name, the variables are: SQLDB_CONNECTION_STRING: for the connection string SQLDB_DATABASENAME: for the database name returns a SQLDBService pointer
func NewWithOptions ¶
func NewWithOptions(options SqlServiceOptions) *SqlService
NewWithOptions Creates a SQL service passing the options object returns a SqlService pointer
func (*SqlService) GlobalDatabase ¶
func (service *SqlService) GlobalDatabase() *SqlFactory
GlobalDatabase Gets the global database factory and initiate it ready for consumption. This will try to only keep a client per session to avoid starvation of the clients returns a SqlDbFactory pointer
func (*SqlService) TenantDatabase ¶
func (service *SqlService) TenantDatabase() *SqlFactory
TenantDatabase Gets the tenant database factory and initiate it ready for consumption if there is no tenant set this will bring the global database and we will treat it as a single tenant system. This will try to only keep a client per session to avoid starvation of the clients returns a SqlFactory pointer
func (*SqlService) WithDatabase ¶
func (service *SqlService) WithDatabase(databaseName string) *SqlService
WithDatabase Sets the global database name returns a SqlService pointer
type SqlServiceOptions ¶
SqlServiceOptions structure