Documentation ¶
Index ¶
Constants ¶
View Source
const ( // ErrUserNotFound when user is not found. ErrUserNotFound = Error("user not found") // ErrUserNameMissing when username is missing. ErrUserNameMissing = Error("user name is missing") // ErrUserAlreadyExist when user already exist in the system. ErrUserAlreadyExist = Error("user already exists") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService represent the service that manage user without implementation detail, this aim to provide API that will be exposed to the handler (HTTP, GRPC)
This part is really up to the implementation detail and expectation. For instance, we could have this service at the handler level if we plan to only use one api exposure.
func (*UserService) Create ¶
func (u *UserService) Create(ctx context.Context, usr *User) error
Create creates a new user. If the user already exist in the storage, ErrUserAlreadyExist will be returned.
type UserStorage ¶
type UserStorage interface { Fetch(ctx context.Context, id string) (*User, error) Create(ctx context.Context, u *User) error Delete(ctx context.Context, id string) error }
UserStorage defines how we store a user. By definition, it is decouple from any backend implementation and its design to be an abstraction of an actual storage.
Click to show internal directories.
Click to hide internal directories.