repository

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package repository implements different repository services required by the user service

Package repository implements different repository services required by the user service

Package repository implements different repository services required by the user service

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUnknownError

func IsUnknownError(err error) bool

IsUnknownError indicates whether the error is of type UnknownError

func IsUserAlreadyExistsError

func IsUserAlreadyExistsError(err error) bool

IsUserAlreadyExistsError indicates whether the error is of type UserAlreadyExistsError

func IsUserByEmailNotFoundError

func IsUserByEmailNotFoundError(err error) bool

IsUserByEmailNotFoundError indicates whether the error is of type UserByEmailNotFoundError

func IsUserNotFoundError

func IsUserNotFoundError(err error) bool

IsUserNotFoundError indicates whether the error is of type UserNotFoundError

func NewUnknownError

func NewUnknownError(message string) error

NewUnknownError creates a new UnknownError error

func NewUnknownErrorWithError

func NewUnknownErrorWithError(message string, err error) error

NewUnknownErrorWithError creates a new UnknownError error

func NewUserAlreadyExistsError

func NewUserAlreadyExistsError() error

NewUserAlreadyExistsError creates a new UserAlreadyExistsError error

func NewUserAlreadyExistsErrorWithError

func NewUserAlreadyExistsErrorWithError(err error) error

NewUserAlreadyExistsErrorWithError creates a new UserAlreadyExistsError error

func NewUserByEmailNotFoundError

func NewUserByEmailNotFoundError(email string) error

NewUserByEmailNotFoundError creates a new UserByEmailNotFoundError error email: Mandatory. The email address that did not match any existing user

func NewUserByEmailNotFoundErrorWithError

func NewUserByEmailNotFoundErrorWithError(email string, err error) error

NewUserByEmailNotFoundErrorWithError creates a new UserByEmailNotFoundError error email: Mandatory. The email address that did not match any existing user

func NewUserNotFoundError

func NewUserNotFoundError(userID string) error

NewUserNotFoundError creates a new UserNotFoundError error userID: Mandatory. The userID that did not match any existing user

func NewUserNotFoundErrorWithError

func NewUserNotFoundErrorWithError(userID string, err error) error

NewUserNotFoundErrorWithError creates a new UserNotFoundError error userID: Mandatory. The userID that did not match any existing user

Types

type CreateUserRequest

type CreateUserRequest struct {
	User models.User
}

CreateUserRequest contains the request to create a new user

type CreateUserResponse

type CreateUserResponse struct {
	UserID string
	User   models.User
	Cursor string
}

CreateUserResponse contains the result of creating a new user

type DeleteUserRequest

type DeleteUserRequest struct {
	UserID string
}

DeleteUserRequest contains the request to delete an existing user

type DeleteUserResponse

type DeleteUserResponse struct {
}

DeleteUserResponse contains the result of deleting an existing user

type ReadUserByEmailRequest

type ReadUserByEmailRequest struct {
	Email string
}

ReadUserByEmailRequest contains the request to read an existing user by email address

type ReadUserByEmailResponse

type ReadUserByEmailResponse struct {
	User models.User
}

ReadUserByEmailResponse contains the result of reading an existing user by email address

type ReadUserRequest

type ReadUserRequest struct {
	UserID string
}

ReadUserRequest contains the request to read an existing user

type ReadUserResponse

type ReadUserResponse struct {
	User models.User
}

ReadUserResponse contains the result of reading an existing user

type RepositoryContract

type RepositoryContract interface {
	// CreateUser creates a new user.
	// ctx: Mandatory The reference to the context
	// request: Mandatory. The request to create a new user
	// Returns either the result of creating new user or error if something goes wrong.
	CreateUser(
		ctx context.Context,
		request *CreateUserRequest) (*CreateUserResponse, error)

	// ReadUser read an existing user
	// ctx: Mandatory The reference to the context
	// request: Mandatory. The request to read an existing user
	// Returns either the result of reading an existing user or error if something goes wrong.
	ReadUser(
		ctx context.Context,
		request *ReadUserRequest) (*ReadUserResponse, error)

	// ReadUserByEmail read an existing user by email address
	// ctx: Mandatory The reference to the context
	// request: Mandatory. The request to read an existing user address
	// Returns either the result of reading an existing user by email address or error if something goes wrong.
	ReadUserByEmail(
		ctx context.Context,
		request *ReadUserByEmailRequest) (*ReadUserByEmailResponse, error)

	// UpdateUser update an existing user
	// ctx: Mandatory The reference to the context
	// request: Mandatory. The request to update an existing user
	// Returns either the result of updateing an existing user or error if something goes wrong.
	UpdateUser(
		ctx context.Context,
		request *UpdateUserRequest) (*UpdateUserResponse, error)

	// DeleteUser delete an existing user
	// ctx: Mandatory The reference to the context
	// request: Mandatory. The request to delete an existing user
	// Returns either the result of deleting an existing user or error if something goes wrong.
	DeleteUser(
		ctx context.Context,
		request *DeleteUserRequest) (*DeleteUserResponse, error)

	// Search returns the list of users that matched the criteria
	// ctx: Mandatory The reference to the context
	// request: Mandatory. The request contains the search criteria
	// Returns the list of users that matched the criteria
	Search(
		ctx context.Context,
		request *SearchRequest) (*SearchResponse, error)
}

RepositoryContract declares the repository service that can create new user, read, update and delete existing users.

type SearchRequest

type SearchRequest struct {
	Pagination     common.Pagination
	SortingOptions []common.SortingOptionPair
	UserIDs        []string
}

SearchRequest contains the filter criteria to look for existing users

type SearchResponse

type SearchResponse struct {
	HasPreviousPage bool
	HasNextPage     bool
	TotalCount      int64
	Users           []models.UserWithCursor
}

SearchResponse contains the list of the users that matched the result

type UnknownError

type UnknownError struct {
	Message string
	Err     error
}

UnknownError indicates that an unknown error has happened

func (UnknownError) Error

func (e UnknownError) Error() string

Error returns message for the UnknownError error type Returns the error nessage

func (UnknownError) Unwrap

func (e UnknownError) Unwrap() error

Unwrap returns the err if provided through NewUnknownErrorWithError function, otherwise returns nil

type UpdateUserRequest

type UpdateUserRequest struct {
	UserID string
	User   models.User
}

UpdateUserRequest contains the request to update an existing user

type UpdateUserResponse

type UpdateUserResponse struct {
	User   models.User
	Cursor string
}

UpdateUserResponse contains the result of updating an existing user

type UserAlreadyExistsError

type UserAlreadyExistsError struct {
	Err error
}

UserAlreadyExistsError indicates that the user with the given information already exists

func (UserAlreadyExistsError) Error

func (e UserAlreadyExistsError) Error() string

Error returns message for the UserAlreadyExistsError error type Returns the error nessage

func (UserAlreadyExistsError) Unwrap

func (e UserAlreadyExistsError) Unwrap() error

Unwrap returns the err if provided through NewUserAlreadyExistsErrorWithError function, otherwise returns nil

type UserByEmailNotFoundError

type UserByEmailNotFoundError struct {
	Email string
	Err   error
}

UserByEmailNotFoundError indicates that the user with the given email address does not exist

func (UserByEmailNotFoundError) Error

func (e UserByEmailNotFoundError) Error() string

Error returns message for the UserByEmailNotFoundError error type Returns the error nessage

func (UserByEmailNotFoundError) Unwrap

func (e UserByEmailNotFoundError) Unwrap() error

Unwrap returns the err if provided through UserByEmailNotFoundError function, otherwise returns nil

type UserNotFoundError

type UserNotFoundError struct {
	UserID string
	Err    error
}

UserNotFoundError indicates that the user with the given userID does not exist

func (UserNotFoundError) Error

func (e UserNotFoundError) Error() string

Error returns message for the UserNotFoundError error type Returns the error nessage

func (UserNotFoundError) Unwrap

func (e UserNotFoundError) Unwrap() error

Unwrap returns the err if provided through NewUserNotFoundErrorWithError function, otherwise returns nil

Directories

Path Synopsis
Package mock_repository is a generated GoMock package.
Package mock_repository is a generated GoMock package.
Package mongodb implements MongoDB repository services
Package mongodb implements MongoDB repository services

Jump to

Keyboard shortcuts

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