Documentation ¶
Index ¶
- type ClientScriptRepository
- type ContextFactory
- type MigrationScriptRepository
- type SQLAdapter
- type SQLCRUD
- func (crud *SQLCRUD) CreateClient(client *models.Client) error
- func (crud *SQLCRUD) CreateClientTable() error
- func (crud *SQLCRUD) CreateMigration(timestamp string) error
- func (crud *SQLCRUD) CreateSessionTable() error
- func (crud *SQLCRUD) CreateUser(user *models.User) error
- func (crud *SQLCRUD) CreateUserRole(role *models.UserRole) error
- func (crud *SQLCRUD) CreateUserRoleTable() error
- func (crud *SQLCRUD) CreateUserTable() error
- func (crud *SQLCRUD) DeleteAllOtherUserSessions(username string, token uuid.UUID) error
- func (crud *SQLCRUD) DeleteAllUserSessions(username string) error
- func (crud *SQLCRUD) DeleteClient(uid uuid.UUID) (bool, error)
- func (crud *SQLCRUD) DeleteMigrationByTimestamp(timestamp string) error
- func (crud *SQLCRUD) DeleteSession(token uuid.UUID) (bool, error)
- func (crud *SQLCRUD) DeleteUser(username string) (bool, error)
- func (crud *SQLCRUD) DeleteUserRole(username string, clientUID uuid.UUID) (bool, error)
- func (crud *SQLCRUD) DropClientTable() error
- func (crud *SQLCRUD) DropSessionTable() error
- func (crud *SQLCRUD) DropUserRoleTable() error
- func (crud *SQLCRUD) DropUserTable() error
- func (crud *SQLCRUD) GetClientByUID(uid uuid.UUID) (*models.Client, error)
- func (crud *SQLCRUD) GetClients() ([]*models.Client, error)
- func (crud *SQLCRUD) GetLatestTimestamp() (timestamp string, hasLatest bool, err error)
- func (crud *SQLCRUD) GetMigrationByTimestamp(timestamp string) (*models.Migration, error)
- func (crud *SQLCRUD) GetSessionByToken(token uuid.UUID) (*models.Session, error)
- func (crud *SQLCRUD) GetUserByUsername(username string) (*models.User, error)
- func (crud *SQLCRUD) GetUserRoleByClientUIDAndUsername(clientUID uuid.UUID, username string) (*models.UserRole, error)
- func (crud *SQLCRUD) GetUserRolesWithLesserRankByClientUID(uid uuid.UUID, rank int) ([]*models.UserRole, error)
- func (crud *SQLCRUD) GetUsersWithLesserRank(rank int) ([]*models.User, error)
- func (crud *SQLCRUD) SaveSession(session *models.Session) error
- func (crud *SQLCRUD) Setup() error
- func (crud *SQLCRUD) UpdateClient(client *models.Client) (bool, error)
- func (crud *SQLCRUD) UpdateUser(user *models.User) (bool, error)
- func (crud *SQLCRUD) UpdateUserPassword(username string, hash []byte) (bool, error)
- func (crud *SQLCRUD) UpdateUserRole(role *models.UserRole) (bool, error)
- type SQLDriver
- type SQLExecutor
- type SQLScriptRepository
- type SQLTransaction
- type SessionScriptRepository
- type UserRoleScriptRepository
- type UserScriptRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientScriptRepository ¶
type ClientScriptRepository interface { CreateClientTableScript() string DropClientTableScript() string CreateClientScript() string GetClientsScript() string GetClientByUIDScript() string UpdateClientScript() string DeleteClientScript() string }
ClientScriptRepository is an interface for fetching client sql scripts.
type ContextFactory ¶
func (ContextFactory) CreateStandardTimeoutContext ¶
func (cf ContextFactory) CreateStandardTimeoutContext() (context.Context, context.CancelFunc)
CreateStandardTimeoutContext creates a context with the configured timeout. It is a child of the configured context and can be canceled by that context's cancel function. Returns the created context and its cancel function.
type MigrationScriptRepository ¶
type MigrationScriptRepository interface { CreateMigrationTableScript() string SaveMigrationScript() string GetMigrationByTimestampScript() string GetLatestTimestampScript() string DeleteMigrationByTimestampScript() string }
MigrationScriptRepository is an interface for fetching migration sql scripts.
type SQLAdapter ¶
type SQLAdapter struct { database.DatabaseAdapter DB *sql.DB SQLDriver SQLDriver ContextFactory ContextFactory // DbKey is the key that will be used to resolve the database's connection string. DbKey string // contains filtered or unexported fields }
func CreateSQLAdpater ¶
func CreateSQLAdpater(dbKey string, driver SQLDriver) *SQLAdapter
CreateSQLAdpater creates a new SQLAdapter with the provided db key and driver.
func (*SQLAdapter) CloseConnection ¶
func (a *SQLAdapter) CloseConnection() error
CloseConnection closes the connection to the SQL database server and resets its db instance. The adapter also calls its cancel function to cancel any child requests that may still be running. Niether the adapter's db instance or context should be used after calling this function. Returns any errors.
func (*SQLAdapter) GetExecutor ¶
func (a *SQLAdapter) GetExecutor() data.DataExecutor
func (*SQLAdapter) OpenConnection ¶
func (a *SQLAdapter) OpenConnection() error
OpenConnection opens the connection to SQL database server using the fields from the database config. Initializes the adapter's context and cancel function, as well as its db instance. Returns any errors.
func (*SQLAdapter) Ping ¶
func (DB *SQLAdapter) Ping() error
Ping pings the SQL database server to verify it can still be reached. Returns an error if it cannot, or if any other errors are encountered.
type SQLCRUD ¶
type SQLCRUD struct { Executor contextExecutor SQLDriver SQLDriver ContextFactory ContextFactory }
func (*SQLCRUD) CreateClientTable ¶
CreateClientTable creates the client table in the database. Returns any errors.
func (*SQLCRUD) CreateMigration ¶
func (*SQLCRUD) CreateSessionTable ¶
CreateSessionTable creates the session table in the database. Returns any errors.
func (*SQLCRUD) CreateUserRoleTable ¶
CreateUserRoleTable creates the user-role table in the database. Returns any errors.
func (*SQLCRUD) CreateUserTable ¶
CreateUserTable creates the user table in the database. Returns any errors.
func (*SQLCRUD) DeleteAllOtherUserSessions ¶
func (*SQLCRUD) DeleteAllUserSessions ¶
func (*SQLCRUD) DeleteMigrationByTimestamp ¶
func (*SQLCRUD) DeleteUserRole ¶
func (*SQLCRUD) DropClientTable ¶
DropClientTable drops the client table from the database. Returns any errors.
func (*SQLCRUD) DropSessionTable ¶
DropSessionTable drops the session table from the database. Returns any errors.
func (*SQLCRUD) DropUserRoleTable ¶
DropUserRoleTable drops the user-role table from the database. Returns any errors.
func (*SQLCRUD) DropUserTable ¶
DropUserTable drops the user table from the database. Returns any errors.
func (*SQLCRUD) GetClientByUID ¶
func (*SQLCRUD) GetLatestTimestamp ¶
func (*SQLCRUD) GetMigrationByTimestamp ¶
func (*SQLCRUD) GetSessionByToken ¶
func (*SQLCRUD) GetUserByUsername ¶
func (*SQLCRUD) GetUserRoleByClientUIDAndUsername ¶
func (*SQLCRUD) GetUserRolesWithLesserRankByClientUID ¶
func (*SQLCRUD) GetUsersWithLesserRank ¶
func (*SQLCRUD) UpdateClient ¶
func (*SQLCRUD) UpdateUserPassword ¶
type SQLDriver ¶
type SQLDriver interface { SQLScriptRepository // GetDriverName returns the name for the driver. GetDriverName() string }
type SQLExecutor ¶
func (*SQLExecutor) CreateTransaction ¶
func (exec *SQLExecutor) CreateTransaction() (data.Transaction, error)
type SQLScriptRepository ¶
type SQLScriptRepository interface { SessionScriptRepository ClientScriptRepository MigrationScriptRepository UserScriptRepository UserRoleScriptRepository }
SQLScriptRepository is an interface for encapsulating other sql script repositories.
type SQLTransaction ¶
type SessionScriptRepository ¶
type SessionScriptRepository interface { CreateSessionTableScript() string DropSessionTableScript() string SaveSessionScript() string GetSessionByTokenScript() string DeleteSessionScript() string DeleteAllUserSessionsScript() string DeleteAllOtherUserSessionsScript() string }
SessionScriptRepository is an interface for fetching session sql scripts.
type UserRoleScriptRepository ¶
type UserRoleScriptRepository interface { CreateUserRoleTableScript() string DropUserRoleTableScript() string CreateUserRoleScript() string GetUserRolesWithLesserRankByClientUIDScript() string GetUserRoleByClientUIDAndUsernameScript() string UpdateUserRoleScript() string DeleteUserRoleScript() string }
UserRoleScriptRepository is an interface for fetching user-role sql scripts.
type UserScriptRepository ¶
type UserScriptRepository interface { CreateUserTableScript() string DropUserTableScript() string CreateUserScript() string GetUsersWithLesserRankScript() string GetUserByUsernameScript() string UpdateUserScript() string UpdateUserPasswordScript() string DeleteUserScript() string }
UserScriptRepository is an interface for fetching user sql scripts.