diff --git a/daemon/http.go b/daemon/http.go index 60bb15b..bee888c 100644 --- a/daemon/http.go +++ b/daemon/http.go @@ -9,17 +9,17 @@ import ( "github.com/mono83/slf/wd" - "elyby/minecraft-skinsystem/repositories" + "elyby/minecraft-skinsystem/interfaces" "elyby/minecraft-skinsystem/ui" ) type Config struct { ListenSpec string - SkinsRepo repositories.SkinsRepository - CapesRepo repositories.CapesRepository - Logger wd.Watchdog - UI ui.Config + SkinsRepo interfaces.SkinsRepository + CapesRepo interfaces.CapesRepository + Logger wd.Watchdog + UI ui.Config } func Run(cfg *Config) error { diff --git a/db/factory.go b/db/factory.go index 5c2eb33..62eaba5 100644 --- a/db/factory.go +++ b/db/factory.go @@ -3,7 +3,7 @@ package db import ( "github.com/spf13/viper" - "elyby/minecraft-skinsystem/repositories" + "elyby/minecraft-skinsystem/interfaces" ) type StorageFactory struct { @@ -11,8 +11,8 @@ type StorageFactory struct { } type RepositoriesCreator interface { - CreateSkinsRepository() (repositories.SkinsRepository, error) - CreateCapesRepository() (repositories.CapesRepository, error) + CreateSkinsRepository() (interfaces.SkinsRepository, error) + CreateCapesRepository() (interfaces.CapesRepository, error) } func (factory *StorageFactory) CreateFactory(backend string) RepositoriesCreator { diff --git a/db/filesystem.go b/db/filesystem.go index 3fb2f03..d8dfc01 100644 --- a/db/filesystem.go +++ b/db/filesystem.go @@ -6,7 +6,7 @@ import ( "strings" "elyby/minecraft-skinsystem/model" - "elyby/minecraft-skinsystem/repositories" + "elyby/minecraft-skinsystem/interfaces" ) type FilesystemFactory struct { @@ -14,11 +14,11 @@ type FilesystemFactory struct { CapesDirName string } -func (f FilesystemFactory) CreateSkinsRepository() (repositories.SkinsRepository, error) { +func (f FilesystemFactory) CreateSkinsRepository() (interfaces.SkinsRepository, error) { panic("skins repository not supported for this storage type") } -func (f FilesystemFactory) CreateCapesRepository() (repositories.CapesRepository, error) { +func (f FilesystemFactory) CreateCapesRepository() (interfaces.CapesRepository, error) { if err := f.validateFactoryConfig(); err != nil { return nil, err } diff --git a/db/redis.go b/db/redis.go index 3c74675..da09a87 100644 --- a/db/redis.go +++ b/db/redis.go @@ -15,7 +15,7 @@ import ( "github.com/mediocregopher/radix.v2/util" "elyby/minecraft-skinsystem/model" - "elyby/minecraft-skinsystem/repositories" + "elyby/minecraft-skinsystem/interfaces" ) type RedisFactory struct { @@ -25,7 +25,7 @@ type RedisFactory struct { connection util.Cmder } -func (f RedisFactory) CreateSkinsRepository() (repositories.SkinsRepository, error) { +func (f RedisFactory) CreateSkinsRepository() (interfaces.SkinsRepository, error) { connection, err := f.getConnection() if err != nil { return nil, err @@ -34,7 +34,7 @@ func (f RedisFactory) CreateSkinsRepository() (repositories.SkinsRepository, err return &redisDb{connection}, nil } -func (f RedisFactory) CreateCapesRepository() (repositories.CapesRepository, error) { +func (f RedisFactory) CreateCapesRepository() (interfaces.CapesRepository, error) { panic("capes repository not supported for this storage type") } diff --git a/repositories/skins.go b/interfaces/repositories.go similarity index 51% rename from repositories/skins.go rename to interfaces/repositories.go index c5b96fb..e8b5695 100644 --- a/repositories/skins.go +++ b/interfaces/repositories.go @@ -1,9 +1,15 @@ -package repositories +package interfaces -import "elyby/minecraft-skinsystem/model" +import ( + "elyby/minecraft-skinsystem/model" +) type SkinsRepository interface { FindByUsername(username string) (*model.Skin, error) FindByUserId(id int) (*model.Skin, error) Save(skin *model.Skin) error } + +type CapesRepository interface { + FindByUsername(username string) (model.Cape, error) +} diff --git a/repositories/capes.go b/repositories/capes.go deleted file mode 100644 index 40b7348..0000000 --- a/repositories/capes.go +++ /dev/null @@ -1,7 +0,0 @@ -package repositories - -import "elyby/minecraft-skinsystem/model" - -type CapesRepository interface { - FindByUsername(username string) (model.Cape, error) -} diff --git a/ui/service.go b/ui/service.go index b589b63..d622b2c 100644 --- a/ui/service.go +++ b/ui/service.go @@ -2,19 +2,19 @@ package ui import ( "github.com/mono83/slf/wd" - "elyby/minecraft-skinsystem/repositories" + "elyby/minecraft-skinsystem/interfaces" ) type uiService struct { - logger wd.Watchdog - skinsRepo repositories.SkinsRepository - capesRepo repositories.CapesRepository + logger wd.Watchdog + skinsRepo interfaces.SkinsRepository + capesRepo interfaces.CapesRepository } func NewUiService( logger wd.Watchdog, - skinsRepo repositories.SkinsRepository, - capesRepo repositories.CapesRepository, + skinsRepo interfaces.SkinsRepository, + capesRepo interfaces.CapesRepository, ) (*uiService, error) { return &uiService{ logger: logger, diff --git a/worker/worker.go b/worker/worker.go index bbdfcbb..142f3af 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -7,12 +7,12 @@ import ( "github.com/streadway/amqp" "elyby/minecraft-skinsystem/model" - "elyby/minecraft-skinsystem/repositories" + "elyby/minecraft-skinsystem/interfaces" ) type Services struct { Channel *amqp.Channel - SkinsRepo repositories.SkinsRepository + SkinsRepo interfaces.SkinsRepository Logger wd.Watchdog }