Documentation ¶
Index ¶
- type DatabaseClient
- type PostgresClient
- func (d *PostgresClient) ChangeUserAdminStatus(userID int64, isAdmin bool) error
- func (d *PostgresClient) Close()
- func (d *PostgresClient) CreateBranchConfig(c *types.BranchConfig) error
- func (d *PostgresClient) CreateRepo(fullName string, userID int64) error
- func (d *PostgresClient) CreateSchema() error
- func (d *PostgresClient) CreateUser(login, pass string, isAdmin bool) error
- func (d *PostgresClient) DeleteBranchConfig(repoID int64, branch string) error
- func (d *PostgresClient) DeleteBranchConfigByID(configID int64) error
- func (d *PostgresClient) DeleteRepoByID(repoID int64) error
- func (d *PostgresClient) FindAllBranchConfigs(repoID int64, q url.Values) ([]types.BranchConfig, error)
- func (d *PostgresClient) FindAllBranchConfigsCount(repoID int64) (int64, error)
- func (d *PostgresClient) FindAllRepos(q url.Values) ([]types.GithubRepo, error)
- func (d *PostgresClient) FindAllReposCount() (int64, error)
- func (d *PostgresClient) FindAllUserRepos(userID int64, q url.Values) ([]types.GithubRepo, error)
- func (d *PostgresClient) FindAllUserReposCount(userID int64) (int64, error)
- func (d *PostgresClient) FindAllUsers(q url.Values) ([]types.User, error)
- func (d *PostgresClient) FindAllUsersCount() (int64, error)
- func (d *PostgresClient) FindBranchConfig(repoID int64, branch string) (*types.BranchConfig, error)
- func (d *PostgresClient) FindRepoByID(repoID int64) (*types.GithubRepo, error)
- func (d *PostgresClient) FindRepoByName(fullName string) (*types.GithubRepo, error)
- func (d *PostgresClient) FindUser(login string) (*types.User, error)
- func (d *PostgresClient) FindUserByID(userID int64) (*types.User, error)
- func (d *PostgresClient) SaveRepo(repo *types.GithubRepo) error
- func (d *PostgresClient) SaveUser(user *types.User) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DatabaseClient ¶
type DatabaseClient interface { Close() CreateSchema() error CreateUser(login, pass string, isAdmin bool) error SaveUser(user *types.User) error FindUser(login string) (*types.User, error) FindUserByID(userID int64) (*types.User, error) FindAllUsers(q url.Values) ([]types.User, error) FindAllUsersCount() (int64, error) ChangeUserAdminStatus(userID int64, isAdmin bool) error CreateRepo(fullName string, userID int64) error SaveRepo(repo *types.GithubRepo) error FindRepoByName(fullName string) (*types.GithubRepo, error) FindRepoByID(repoID int64) (*types.GithubRepo, error) DeleteRepoByID(repoID int64) error FindAllUserRepos(userID int64, q url.Values) ([]types.GithubRepo, error) FindAllUserReposCount(userID int64) (int64, error) FindAllRepos(q url.Values) ([]types.GithubRepo, error) FindAllReposCount() (int64, error) CreateBranchConfig(c *types.BranchConfig) error FindBranchConfig(repoID int64, branch string) (*types.BranchConfig, error) DeleteBranchConfig(repoID int64, branch string) error DeleteBranchConfigByID(configID int64) error FindAllBranchConfigs(repoID int64, q url.Values) ([]types.BranchConfig, error) FindAllBranchConfigsCount(repoID int64) (int64, error) }
DatabaseClient provides interface for data access layer operations
type PostgresClient ¶
type PostgresClient struct {
// contains filtered or unexported fields
}
PostgresClient provides data access layer to objects in Postgres. implements DatabaseClient interface
func NewPGClient ¶
func NewPGClient(config types.PGClientConfig) *PostgresClient
NewPGClient creates new copy of PostgresClient
func (*PostgresClient) ChangeUserAdminStatus ¶
func (d *PostgresClient) ChangeUserAdminStatus(userID int64, isAdmin bool) error
func (*PostgresClient) Close ¶
func (d *PostgresClient) Close()
Close gracefully closes db connection
func (*PostgresClient) CreateBranchConfig ¶
func (d *PostgresClient) CreateBranchConfig(c *types.BranchConfig) error
CreateBranchConfig creates repo branch config from provided struct
func (*PostgresClient) CreateRepo ¶
func (d *PostgresClient) CreateRepo(fullName string, userID int64) error
CreateRepo creates github repo record with provided full name and owner id
func (*PostgresClient) CreateSchema ¶
func (d *PostgresClient) CreateSchema() error
CreateSchema creates database tables if they not exist
func (*PostgresClient) CreateUser ¶
func (d *PostgresClient) CreateUser(login, pass string, isAdmin bool) error
CreateUser creates new user with provided credentials and admin status
func (*PostgresClient) DeleteBranchConfig ¶
func (d *PostgresClient) DeleteBranchConfig(repoID int64, branch string) error
DeleteBranchConfig deletes branch config record with provided repo id and branch name if it exists
func (*PostgresClient) DeleteBranchConfigByID ¶
func (d *PostgresClient) DeleteBranchConfigByID(configID int64) error
DeleteBranchConfigByID deletes branch config record with provided repo id if it exists
func (*PostgresClient) DeleteRepoByID ¶
func (d *PostgresClient) DeleteRepoByID(repoID int64) error
DeleteRepoByID deletes repo record with provided id if it exists
func (*PostgresClient) FindAllBranchConfigs ¶
func (d *PostgresClient) FindAllBranchConfigs(repoID int64, q url.Values) ([]types.BranchConfig, error)
FindAllBranchConfigs returns all repo branch configs for provided repo id with pagination support (by passing query params of request)
func (*PostgresClient) FindAllBranchConfigsCount ¶
func (d *PostgresClient) FindAllBranchConfigsCount(repoID int64) (int64, error)
func (*PostgresClient) FindAllRepos ¶
func (d *PostgresClient) FindAllRepos(q url.Values) ([]types.GithubRepo, error)
func (*PostgresClient) FindAllReposCount ¶
func (d *PostgresClient) FindAllReposCount() (int64, error)
func (*PostgresClient) FindAllUserRepos ¶
func (d *PostgresClient) FindAllUserRepos(userID int64, q url.Values) ([]types.GithubRepo, error)
FindAllUserRepos returns all repo records for provided user with pagination support (by passing query params of request)
func (*PostgresClient) FindAllUserReposCount ¶
func (d *PostgresClient) FindAllUserReposCount(userID int64) (int64, error)
func (*PostgresClient) FindAllUsers ¶
FindAllUsers finds all users in database with pagination support (by passing query params of request)
func (*PostgresClient) FindAllUsersCount ¶
func (d *PostgresClient) FindAllUsersCount() (int64, error)
FindAllUsersCount returns count of all users in database
func (*PostgresClient) FindBranchConfig ¶
func (d *PostgresClient) FindBranchConfig(repoID int64, branch string) (*types.BranchConfig, error)
FindBranchConfig returns repo branch config with provided repo id and branch name if it exists
func (*PostgresClient) FindRepoByID ¶
func (d *PostgresClient) FindRepoByID(repoID int64) (*types.GithubRepo, error)
FindRepoByID returns repo struct with provided id if it exists
func (*PostgresClient) FindRepoByName ¶
func (d *PostgresClient) FindRepoByName(fullName string) (*types.GithubRepo, error)
FindRepoByName returns repo struct with provided full name if it exists
func (*PostgresClient) FindUser ¶
func (d *PostgresClient) FindUser(login string) (*types.User, error)
FindUser returns user struct with provided login if it exists
func (*PostgresClient) FindUserByID ¶
func (d *PostgresClient) FindUserByID(userID int64) (*types.User, error)
FindUserByID returns user struct with provided id if it exists
func (*PostgresClient) SaveRepo ¶
func (d *PostgresClient) SaveRepo(repo *types.GithubRepo) error
SaveRepo writes provided github repo to db