Documentation ¶
Index ¶
- func New(cfg *config.Config) (*sqlx.DB, error)
- func NewConflictError(label string, url string, err error) error
- func NewConsumer(cfg *config.Config) *consumer
- func NewLabelError(label string, err error) error
- func NewProducer(cfg *config.Config) *producer
- func NewSQLConsumer(db *sqlx.DB) *consumerSQL
- func NewSQLProducer(db *sqlx.DB) *producerSQL
- func NewTimeError(err error) error
- type ConflictError
- type InFiles
- func (i *InFiles) Delete(ctx context.Context, u *entity.User) error
- func (i *InFiles) Get(ctx context.Context, sh *entity.Shorturl) (*entity.Shorturl, error)
- func (i *InFiles) GetAll(ctx context.Context, u *entity.User) (*entity.User, error)
- func (i *InFiles) GetAllUrls() (entity.CountURLs, error)
- func (i *InFiles) GetAllUsers() (entity.CountUsers, error)
- func (i *InFiles) Post(ctx context.Context, sh *entity.Shorturl) error
- func (i *InFiles) Put(ctx context.Context, sh *entity.Shorturl) error
- func (i *InFiles) Read() error
- func (i *InFiles) Save() error
- type InMemory
- func (s *InMemory) Delete(ctx context.Context, u *entity.User) error
- func (s *InMemory) Get(ctx context.Context, sh *entity.Shorturl) (*entity.Shorturl, error)
- func (s *InMemory) GetAll(ctx context.Context, u *entity.User) (*entity.User, error)
- func (s *InMemory) GetAllUrls() (entity.CountURLs, error)
- func (s *InMemory) GetAllUsers() (entity.CountUsers, error)
- func (s *InMemory) Post(ctx context.Context, sh *entity.Shorturl) error
- func (s *InMemory) Put(ctx context.Context, sh *entity.Shorturl) error
- func (s *InMemory) Read() error
- func (s *InMemory) Save() error
- type InSQL
- func (i *InSQL) Delete(ctx context.Context, u *entity.User) error
- func (i *InSQL) Get(ctx context.Context, sh *entity.Shorturl) (*entity.Shorturl, error)
- func (i *InSQL) GetAll(ctx context.Context, u *entity.User) (*entity.User, error)
- func (i *InSQL) GetAllUrls() (entity.CountURLs, error)
- func (i *InSQL) GetAllUsers() (entity.CountUsers, error)
- func (i *InSQL) Post(ctx context.Context, sh *entity.Shorturl) error
- func (i *InSQL) Put(ctx context.Context, sh *entity.Shorturl) error
- func (i *InSQL) Read() error
- func (i *InSQL) Save() error
- type LabelError
- type TimeError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConflictError ¶
NewConflictError упаковывает ошибку err в тип LabelError.
func NewLabelError ¶
NewLabelError упаковывает ошибку err в тип LabelError.
func NewTimeError ¶
NewTimeError упаковывает ошибку err в тип TimeError c текущим временем.
Types ¶
type ConflictError ¶
type ConflictError struct { Err error Label string // метка должна быть в верхнем регистре URL string // уже имеющийся сокращённый URL }
ConflictError описывает ошибку с дополнительной меткой и значением.
func (*ConflictError) Error ¶
func (ce *ConflictError) Error() string
Error добавляет поддержку интерфейса error для типа LabelError.
type InFiles ¶
type InFiles struct {
// contains filtered or unexported fields
}
InFiles -.
func NewInFiles ¶
NewInFiles слой взаимодействия с файловым хранилищем
func (*InFiles) Delete ¶
Delete - удаляет URLы переданный в запросе, только если есть права данного пользователя
func (*InFiles) GetAllUrls ¶
GetAllUrls получить все URL
func (*InFiles) GetAllUsers ¶
func (i *InFiles) GetAllUsers() (entity.CountUsers, error)
GetAllUsers получить всех пользователей
type InMemory ¶
type InMemory struct {
// contains filtered or unexported fields
}
InMemory Если вам нужно защитить доступ к простой структуре данных, такой как слайс, или map, или что-нибудь своё, и если интерфейс доступа к этой структуре данных прост и прямолинеен — начинайте с мьютекса. Это также помогает спрятать «грязные» подробности кода блокировки в вашем API. Конечные пользователи вашей структуры не должны заботиться о том, как она делает внутреннюю синхронизацию. Определяя структуру, в которой мьютекс должен защищать одно или больше значений, помещайте мьютекс выше тех полей, доступ к которым, он будет защищать.
func NewInMemory ¶
NewInMemory слой взаимодействия с хранилищем в памяти.
func (*InMemory) Delete ¶
Delete - удаляет URLы переданный в запросе, только если есть права данного пользователя.
func (*InMemory) Get ¶
Get получить конкретный URL по идентификатору этого URL и только если этот линк записал текущий пользователь.
func (*InMemory) GetAllUrls ¶
GetAllUrls получить все URL
func (*InMemory) GetAllUsers ¶
func (s *InMemory) GetAllUsers() (entity.CountUsers, error)
GetAllUsers получить всех пользователей TODO не правильно работает, переделать
type InSQL ¶
type InSQL struct {
// contains filtered or unexported fields
}
InSQL .-
func (*InSQL) GetAllUrls ¶
GetAllUrls - получить все url-адреса не зависимо от авторизации.
func (*InSQL) GetAllUsers ¶
func (i *InSQL) GetAllUsers() (entity.CountUsers, error)
GetAllUsers - получить все url-адреса не зависимо от авторизации.
type LabelError ¶
LabelError описывает ошибку с дополнительной меткой.
func (*LabelError) Error ¶
func (le *LabelError) Error() string
Error добавляет поддержку интерфейса error для типа LabelError.