ソースを参照

Update services

Dima 1 年間 前
コミット
cfd6f0f4f1

+ 1 - 3
.gitignore

@@ -1,5 +1,3 @@
 /.idea/
 /coverage.out
-/config/.env
-/build/docker/mysql/
-/build/coverage.out
+/.env

+ 0 - 19
config/.env.example

@@ -1,19 +0,0 @@
-APP_PORT=8080
-
-DB_HOST=localhost
-DB_PORT=3306
-DB_NAME=
-DB_USER=
-DB_PASSWORD=
-
-SMTP_HOST=
-SMTP_PORT=
-SMTP_USER=
-SMTP_PASSWORD=
-
-STATIC_VERSION=1
-GA_ENABLED=true
-
-ADMIN_EMAIL=
-ADMIN_USER=
-ADMIN_PASSWORD=

+ 13 - 0
go.mod

@@ -11,20 +11,33 @@ require (
 	github.com/gofiber/fiber/v2 v2.38.1
 	github.com/gofiber/template v1.7.1
 	github.com/gojuno/minimock/v3 v3.0.10
+	github.com/spf13/viper v1.10.0
 	github.com/stretchr/testify v1.7.0
 )
 
 require (
 	github.com/andybalholm/brotli v1.0.4 // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
+	github.com/fsnotify/fsnotify v1.5.1 // indirect
+	github.com/hashicorp/hcl v1.0.0 // indirect
 	github.com/klauspost/compress v1.15.9 // indirect
 	github.com/leodido/go-urn v1.2.1 // indirect
+	github.com/magiconair/properties v1.8.5 // indirect
+	github.com/mitchellh/mapstructure v1.4.3 // indirect
+	github.com/pelletier/go-toml v1.9.4 // indirect
 	github.com/pmezard/go-difflib v1.0.0 // indirect
+	github.com/spf13/afero v1.6.0 // indirect
+	github.com/spf13/cast v1.4.1 // indirect
+	github.com/spf13/jwalterweatherman v1.1.0 // indirect
+	github.com/spf13/pflag v1.0.5 // indirect
+	github.com/subosito/gotenv v1.2.0 // indirect
 	github.com/valyala/bytebufferpool v1.0.0 // indirect
 	github.com/valyala/fasthttp v1.40.0 // indirect
 	github.com/valyala/tcplisten v1.0.0 // indirect
 	golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect
 	golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2 // indirect
 	golang.org/x/text v0.3.7 // indirect
+	gopkg.in/ini.v1 v1.66.2 // indirect
+	gopkg.in/yaml.v2 v2.4.0 // indirect
 	gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
 )

+ 13 - 0
go.sum

@@ -118,6 +118,7 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
 github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
 github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
 github.com/flosch/pongo2/v4 v4.0.2/go.mod h1:B5ObFANs/36VwxxlgKpdchIJHMvHB562PW+BWPhwZD8=
+github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
 github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
 github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
 github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
@@ -243,6 +244,7 @@ github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b
 github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
 github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
 github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
+github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
 github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
 github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
 github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY=
@@ -284,6 +286,7 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
 github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
 github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
 github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w=
+github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
 github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
 github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
 github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
@@ -306,6 +309,7 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk
 github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
 github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
 github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
 github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -317,6 +321,7 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
 github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
 github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
 github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
+github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM=
 github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
 github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -352,11 +357,16 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
 github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
 github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4=
+github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
 github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
+github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA=
 github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
 github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4=
+github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
 github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
+github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
 github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/spf13/viper v1.10.0 h1:mXH0UwHS4D2HwWZa75im4xIQynLfblmWV7qcWpfv0yk=
 github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -367,6 +377,7 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
 github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
 github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
 github.com/twitchtv/twirp v5.8.0+incompatible/go.mod h1:RRJoFSAmTEh2weEqWtpPE3vFK5YBhA6bqp2l1kfCC5A=
@@ -816,6 +827,7 @@ gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8
 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
 gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
+gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=
 gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
 gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
@@ -823,6 +835,7 @@ gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
 gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=

+ 24 - 7
internal/interfaces/env.go

@@ -2,18 +2,35 @@ package interfaces
 
 type Env interface {
 	GetAppPort() string
-	GetDBPort() string
+
 	GetDBHost() string
+	GetDBPort() string
 	GetDBName() string
 	GetDBUser() string
 	GetDBPassword() string
-	GetSMTPPort() string
+
+	GetDBMaxOpenConns() int
+	GetDBMaxIdleConns() int
+	GetDBMaxConnLifetime() int
+	GetDBMaxIdleConnLifetime() int
+
+	GetCORSAllowOrigins() string
+	GetCORSAllowMethods() string
+
 	GetSMTPHost() string
+	GetSMTPPort() string
 	GetSMTPUser() string
 	GetSMTPPassword() string
-	GetAdminEmail() string
-	GetAdminUser() string
-	GetAdminPassword() string
-	GetStaticVersion() string
-	IsGAEnabled() bool
+
+	GetJWTSecretKey() string
+	GetJWTLifetime() int
+
+	GetBasicAuthUser() string
+	GetBasicAuthPassword() string
+
+	GetErrorsEmail() string
+
+	GetStaticVersion() int
+
+	GetGAKey() string
 }

+ 33 - 27
internal/service_provider/sp.go

@@ -10,24 +10,36 @@ import (
 )
 
 type ServiceProvider struct {
-	env                  interfaces.IEnv
-	cache                interfaces.ICache
-	mailer               interfaces.IMailer
-	articleRepository    interfaces.IArticleRepository
-	tagRepository        interfaces.ITagRepository
-	articleTagRepository interfaces.IArticleTagRepository
+	env                  interfaces.Env
+	cache                interfaces.Cache
+	mailer               interfaces.Mailer
+	articleRepository    interfaces.ArticleRepository
+	tagRepository        interfaces.TagRepository
+	articleTagRepository interfaces.ArticleTagRepository
 }
 
-func Init() (interfaces.IServiceProvider, error) {
+func Init() (interfaces.ServiceProvider, error) {
 	sp := &ServiceProvider{}
 
-	// Init env service
+	// Init services
 	env, err := envService.Init()
 	if err != nil {
 		return nil, err
 	}
 	sp.env = env
 
+	cache, err := cacheService.Init()
+	if err != nil {
+		return nil, err
+	}
+	sp.cache = cache
+
+	mailer, err := mailService.Init(sp.env)
+	if err != nil {
+		return nil, err
+	}
+	sp.mailer = mailer
+
 	db, err := dbService.Init(env)
 	if err != nil {
 		return nil, err
@@ -38,55 +50,49 @@ func Init() (interfaces.IServiceProvider, error) {
 	sp.tagRepository = repositories.InitTagRepository(db)
 	sp.articleTagRepository = repositories.InitArticleTagRepository(db)
 
-	// Init cache service
-	sp.cache = cacheService.Init()
-
-	// Init mailer
-	sp.mailer = mailService.Init(sp.env)
-
 	return sp, nil
 }
 
-func (sp *ServiceProvider) GetEnvService() interfaces.IEnv {
+func (sp *ServiceProvider) GetEnvService() interfaces.Env {
 	return sp.env
 }
 
-func (sp *ServiceProvider) GetCacheService() interfaces.ICache {
+func (sp *ServiceProvider) GetCacheService() interfaces.Cache {
 	return sp.cache
 }
 
-func (sp *ServiceProvider) GetMailerService() interfaces.IMailer {
+func (sp *ServiceProvider) GetMailerService() interfaces.Mailer {
 	return sp.mailer
 }
 
-func (sp *ServiceProvider) GetArticleRepository() interfaces.IArticleRepository {
+func (sp *ServiceProvider) GetArticleRepository() interfaces.ArticleRepository {
 	return sp.articleRepository
 }
 
-func (sp *ServiceProvider) GetTagRepository() interfaces.ITagRepository {
+func (sp *ServiceProvider) GetTagRepository() interfaces.TagRepository {
 	return sp.tagRepository
 }
 
-func (sp *ServiceProvider) GetArticleTagRepository() interfaces.IArticleTagRepository {
+func (sp *ServiceProvider) GetArticleTagRepository() interfaces.ArticleTagRepository {
 	return sp.articleTagRepository
 }
 
-func InitMock(deps ...interface{}) interfaces.IServiceProvider {
+func InitMock(deps ...interface{}) interfaces.ServiceProvider {
 	sp := ServiceProvider{}
 
 	for _, d := range deps {
 		switch s := d.(type) {
-		case interfaces.ICache:
+		case interfaces.Cache:
 			sp.cache = s
-		case interfaces.IEnv:
+		case interfaces.Env:
 			sp.env = s
-		case interfaces.IMailer:
+		case interfaces.Mailer:
 			sp.mailer = s
-		case interfaces.IArticleRepository:
+		case interfaces.ArticleRepository:
 			sp.articleRepository = s
-		case interfaces.IArticleTagRepository:
+		case interfaces.ArticleTagRepository:
 			sp.articleTagRepository = s
-		case interfaces.ITagRepository:
+		case interfaces.TagRepository:
 			sp.tagRepository = s
 		}
 	}

+ 3 - 3
internal/services/cache/cache.go

@@ -2,7 +2,7 @@ package cache
 
 //go:generate mkdir -p mocks
 //go:generate rm -rf ./mocks/*_minimock.go
-//go:generate minimock -i ../../interfaces.ICache -o ./mocks/ -s "_minimock.go"
+//go:generate minimock -i ../../interfaces.Cache -o ./mocks/ -s "_minimock.go"
 
 import (
 	"sync"
@@ -15,10 +15,10 @@ type cache struct {
 	sync.RWMutex
 }
 
-func Init() interfaces.ICache {
+func Init() (interfaces.Cache, error) {
 	return &cache{
 		data: make(map[string]interface{}),
-	}
+	}, nil
 }
 
 func (c *cache) Get(key string) (interface{}, bool) {

+ 156 - 156
internal/services/cache/mocks/i_cache_minimock.go → internal/services/cache/mocks/cache_minimock.go

@@ -2,7 +2,7 @@ package mocks
 
 // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
 
-//go:generate minimock -i github.com/dmitriygnatenko/internal/interfaces.ICache -o ./mocks/i_cache_minimock.go -n ICacheMock
+//go:generate minimock -i github.com/dmitriygnatenko/internal/interfaces.Cache -o ./mocks/cache_minimock.go -n CacheMock
 
 import (
 	"sync"
@@ -12,77 +12,77 @@ import (
 	"github.com/gojuno/minimock/v3"
 )
 
-// ICacheMock implements interfaces.ICache
-type ICacheMock struct {
+// CacheMock implements interfaces.Cache
+type CacheMock struct {
 	t minimock.Tester
 
 	funcFlushAll          func()
 	inspectFuncFlushAll   func()
 	afterFlushAllCounter  uint64
 	beforeFlushAllCounter uint64
-	FlushAllMock          mICacheMockFlushAll
+	FlushAllMock          mCacheMockFlushAll
 
 	funcGet          func(key string) (p1 interface{}, b1 bool)
 	inspectFuncGet   func(key string)
 	afterGetCounter  uint64
 	beforeGetCounter uint64
-	GetMock          mICacheMockGet
+	GetMock          mCacheMockGet
 
 	funcSet          func(key string, value interface{})
 	inspectFuncSet   func(key string, value interface{})
 	afterSetCounter  uint64
 	beforeSetCounter uint64
-	SetMock          mICacheMockSet
+	SetMock          mCacheMockSet
 }
 
-// NewICacheMock returns a mock for interfaces.ICache
-func NewICacheMock(t minimock.Tester) *ICacheMock {
-	m := &ICacheMock{t: t}
+// NewCacheMock returns a mock for interfaces.Cache
+func NewCacheMock(t minimock.Tester) *CacheMock {
+	m := &CacheMock{t: t}
 	if controller, ok := t.(minimock.MockController); ok {
 		controller.RegisterMocker(m)
 	}
 
-	m.FlushAllMock = mICacheMockFlushAll{mock: m}
+	m.FlushAllMock = mCacheMockFlushAll{mock: m}
 
-	m.GetMock = mICacheMockGet{mock: m}
-	m.GetMock.callArgs = []*ICacheMockGetParams{}
+	m.GetMock = mCacheMockGet{mock: m}
+	m.GetMock.callArgs = []*CacheMockGetParams{}
 
-	m.SetMock = mICacheMockSet{mock: m}
-	m.SetMock.callArgs = []*ICacheMockSetParams{}
+	m.SetMock = mCacheMockSet{mock: m}
+	m.SetMock.callArgs = []*CacheMockSetParams{}
 
 	return m
 }
 
-type mICacheMockFlushAll struct {
-	mock               *ICacheMock
-	defaultExpectation *ICacheMockFlushAllExpectation
-	expectations       []*ICacheMockFlushAllExpectation
+type mCacheMockFlushAll struct {
+	mock               *CacheMock
+	defaultExpectation *CacheMockFlushAllExpectation
+	expectations       []*CacheMockFlushAllExpectation
 }
 
-// ICacheMockFlushAllExpectation specifies expectation struct of the ICache.FlushAll
-type ICacheMockFlushAllExpectation struct {
-	mock *ICacheMock
+// CacheMockFlushAllExpectation specifies expectation struct of the Cache.FlushAll
+type CacheMockFlushAllExpectation struct {
+	mock *CacheMock
 
 	Counter uint64
 }
 
-// Expect sets up expected params for ICache.FlushAll
-func (mmFlushAll *mICacheMockFlushAll) Expect() *mICacheMockFlushAll {
+// Expect sets up expected params for Cache.FlushAll
+func (mmFlushAll *mCacheMockFlushAll) Expect() *mCacheMockFlushAll {
 	if mmFlushAll.mock.funcFlushAll != nil {
-		mmFlushAll.mock.t.Fatalf("ICacheMock.FlushAll mock is already set by Set")
+		mmFlushAll.mock.t.Fatalf("CacheMock.FlushAll mock is already set by Set")
 	}
 
 	if mmFlushAll.defaultExpectation == nil {
-		mmFlushAll.defaultExpectation = &ICacheMockFlushAllExpectation{}
+		mmFlushAll.defaultExpectation = &CacheMockFlushAllExpectation{}
 	}
 
 	return mmFlushAll
 }
 
-// Inspect accepts an inspector function that has same arguments as the ICache.FlushAll
-func (mmFlushAll *mICacheMockFlushAll) Inspect(f func()) *mICacheMockFlushAll {
+// Inspect accepts an inspector function that has same arguments as the Cache.FlushAll
+func (mmFlushAll *mCacheMockFlushAll) Inspect(f func()) *mCacheMockFlushAll {
 	if mmFlushAll.mock.inspectFuncFlushAll != nil {
-		mmFlushAll.mock.t.Fatalf("Inspect function is already set for ICacheMock.FlushAll")
+		mmFlushAll.mock.t.Fatalf("Inspect function is already set for CacheMock.FlushAll")
 	}
 
 	mmFlushAll.mock.inspectFuncFlushAll = f
@@ -90,35 +90,35 @@ func (mmFlushAll *mICacheMockFlushAll) Inspect(f func()) *mICacheMockFlushAll {
 	return mmFlushAll
 }
 
-// Return sets up results that will be returned by ICache.FlushAll
-func (mmFlushAll *mICacheMockFlushAll) Return() *ICacheMock {
+// Return sets up results that will be returned by Cache.FlushAll
+func (mmFlushAll *mCacheMockFlushAll) Return() *CacheMock {
 	if mmFlushAll.mock.funcFlushAll != nil {
-		mmFlushAll.mock.t.Fatalf("ICacheMock.FlushAll mock is already set by Set")
+		mmFlushAll.mock.t.Fatalf("CacheMock.FlushAll mock is already set by Set")
 	}
 
 	if mmFlushAll.defaultExpectation == nil {
-		mmFlushAll.defaultExpectation = &ICacheMockFlushAllExpectation{mock: mmFlushAll.mock}
+		mmFlushAll.defaultExpectation = &CacheMockFlushAllExpectation{mock: mmFlushAll.mock}
 	}
 
 	return mmFlushAll.mock
 }
 
-//Set uses given function f to mock the ICache.FlushAll method
-func (mmFlushAll *mICacheMockFlushAll) Set(f func()) *ICacheMock {
+// Set uses given function f to mock the Cache.FlushAll method
+func (mmFlushAll *mCacheMockFlushAll) Set(f func()) *CacheMock {
 	if mmFlushAll.defaultExpectation != nil {
-		mmFlushAll.mock.t.Fatalf("Default expectation is already set for the ICache.FlushAll method")
+		mmFlushAll.mock.t.Fatalf("Default expectation is already set for the Cache.FlushAll method")
 	}
 
 	if len(mmFlushAll.expectations) > 0 {
-		mmFlushAll.mock.t.Fatalf("Some expectations are already set for the ICache.FlushAll method")
+		mmFlushAll.mock.t.Fatalf("Some expectations are already set for the Cache.FlushAll method")
 	}
 
 	mmFlushAll.mock.funcFlushAll = f
 	return mmFlushAll.mock
 }
 
-// FlushAll implements interfaces.ICache
-func (mmFlushAll *ICacheMock) FlushAll() {
+// FlushAll implements interfaces.Cache
+func (mmFlushAll *CacheMock) FlushAll() {
 	mm_atomic.AddUint64(&mmFlushAll.beforeFlushAllCounter, 1)
 	defer mm_atomic.AddUint64(&mmFlushAll.afterFlushAllCounter, 1)
 
@@ -136,23 +136,23 @@ func (mmFlushAll *ICacheMock) FlushAll() {
 		mmFlushAll.funcFlushAll()
 		return
 	}
-	mmFlushAll.t.Fatalf("Unexpected call to ICacheMock.FlushAll.")
+	mmFlushAll.t.Fatalf("Unexpected call to CacheMock.FlushAll.")
 
 }
 
-// FlushAllAfterCounter returns a count of finished ICacheMock.FlushAll invocations
-func (mmFlushAll *ICacheMock) FlushAllAfterCounter() uint64 {
+// FlushAllAfterCounter returns a count of finished CacheMock.FlushAll invocations
+func (mmFlushAll *CacheMock) FlushAllAfterCounter() uint64 {
 	return mm_atomic.LoadUint64(&mmFlushAll.afterFlushAllCounter)
 }
 
-// FlushAllBeforeCounter returns a count of ICacheMock.FlushAll invocations
-func (mmFlushAll *ICacheMock) FlushAllBeforeCounter() uint64 {
+// FlushAllBeforeCounter returns a count of CacheMock.FlushAll invocations
+func (mmFlushAll *CacheMock) FlushAllBeforeCounter() uint64 {
 	return mm_atomic.LoadUint64(&mmFlushAll.beforeFlushAllCounter)
 }
 
 // MinimockFlushAllDone returns true if the count of the FlushAll invocations corresponds
 // the number of defined expectations
-func (m *ICacheMock) MinimockFlushAllDone() bool {
+func (m *CacheMock) MinimockFlushAllDone() bool {
 	for _, e := range m.FlushAllMock.expectations {
 		if mm_atomic.LoadUint64(&e.Counter) < 1 {
 			return false
@@ -171,62 +171,62 @@ func (m *ICacheMock) MinimockFlushAllDone() bool {
 }
 
 // MinimockFlushAllInspect logs each unmet expectation
-func (m *ICacheMock) MinimockFlushAllInspect() {
+func (m *CacheMock) MinimockFlushAllInspect() {
 	for _, e := range m.FlushAllMock.expectations {
 		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Error("Expected call to ICacheMock.FlushAll")
+			m.t.Error("Expected call to CacheMock.FlushAll")
 		}
 	}
 
 	// if default expectation was set then invocations count should be greater than zero
 	if m.FlushAllMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterFlushAllCounter) < 1 {
-		m.t.Error("Expected call to ICacheMock.FlushAll")
+		m.t.Error("Expected call to CacheMock.FlushAll")
 	}
 	// if func was set then invocations count should be greater than zero
 	if m.funcFlushAll != nil && mm_atomic.LoadUint64(&m.afterFlushAllCounter) < 1 {
-		m.t.Error("Expected call to ICacheMock.FlushAll")
+		m.t.Error("Expected call to CacheMock.FlushAll")
 	}
 }
 
-type mICacheMockGet struct {
-	mock               *ICacheMock
-	defaultExpectation *ICacheMockGetExpectation
-	expectations       []*ICacheMockGetExpectation
+type mCacheMockGet struct {
+	mock               *CacheMock
+	defaultExpectation *CacheMockGetExpectation
+	expectations       []*CacheMockGetExpectation
 
-	callArgs []*ICacheMockGetParams
+	callArgs []*CacheMockGetParams
 	mutex    sync.RWMutex
 }
 
-// ICacheMockGetExpectation specifies expectation struct of the ICache.Get
-type ICacheMockGetExpectation struct {
-	mock    *ICacheMock
-	params  *ICacheMockGetParams
-	results *ICacheMockGetResults
+// CacheMockGetExpectation specifies expectation struct of the Cache.Get
+type CacheMockGetExpectation struct {
+	mock    *CacheMock
+	params  *CacheMockGetParams
+	results *CacheMockGetResults
 	Counter uint64
 }
 
-// ICacheMockGetParams contains parameters of the ICache.Get
-type ICacheMockGetParams struct {
+// CacheMockGetParams contains parameters of the Cache.Get
+type CacheMockGetParams struct {
 	key string
 }
 
-// ICacheMockGetResults contains results of the ICache.Get
-type ICacheMockGetResults struct {
+// CacheMockGetResults contains results of the Cache.Get
+type CacheMockGetResults struct {
 	p1 interface{}
 	b1 bool
 }
 
-// Expect sets up expected params for ICache.Get
-func (mmGet *mICacheMockGet) Expect(key string) *mICacheMockGet {
+// Expect sets up expected params for Cache.Get
+func (mmGet *mCacheMockGet) Expect(key string) *mCacheMockGet {
 	if mmGet.mock.funcGet != nil {
-		mmGet.mock.t.Fatalf("ICacheMock.Get mock is already set by Set")
+		mmGet.mock.t.Fatalf("CacheMock.Get mock is already set by Set")
 	}
 
 	if mmGet.defaultExpectation == nil {
-		mmGet.defaultExpectation = &ICacheMockGetExpectation{}
+		mmGet.defaultExpectation = &CacheMockGetExpectation{}
 	}
 
-	mmGet.defaultExpectation.params = &ICacheMockGetParams{key}
+	mmGet.defaultExpectation.params = &CacheMockGetParams{key}
 	for _, e := range mmGet.expectations {
 		if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
 			mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
@@ -236,10 +236,10 @@ func (mmGet *mICacheMockGet) Expect(key string) *mICacheMockGet {
 	return mmGet
 }
 
-// Inspect accepts an inspector function that has same arguments as the ICache.Get
-func (mmGet *mICacheMockGet) Inspect(f func(key string)) *mICacheMockGet {
+// Inspect accepts an inspector function that has same arguments as the Cache.Get
+func (mmGet *mCacheMockGet) Inspect(f func(key string)) *mCacheMockGet {
 	if mmGet.mock.inspectFuncGet != nil {
-		mmGet.mock.t.Fatalf("Inspect function is already set for ICacheMock.Get")
+		mmGet.mock.t.Fatalf("Inspect function is already set for CacheMock.Get")
 	}
 
 	mmGet.mock.inspectFuncGet = f
@@ -247,56 +247,56 @@ func (mmGet *mICacheMockGet) Inspect(f func(key string)) *mICacheMockGet {
 	return mmGet
 }
 
-// Return sets up results that will be returned by ICache.Get
-func (mmGet *mICacheMockGet) Return(p1 interface{}, b1 bool) *ICacheMock {
+// Return sets up results that will be returned by Cache.Get
+func (mmGet *mCacheMockGet) Return(p1 interface{}, b1 bool) *CacheMock {
 	if mmGet.mock.funcGet != nil {
-		mmGet.mock.t.Fatalf("ICacheMock.Get mock is already set by Set")
+		mmGet.mock.t.Fatalf("CacheMock.Get mock is already set by Set")
 	}
 
 	if mmGet.defaultExpectation == nil {
-		mmGet.defaultExpectation = &ICacheMockGetExpectation{mock: mmGet.mock}
+		mmGet.defaultExpectation = &CacheMockGetExpectation{mock: mmGet.mock}
 	}
-	mmGet.defaultExpectation.results = &ICacheMockGetResults{p1, b1}
+	mmGet.defaultExpectation.results = &CacheMockGetResults{p1, b1}
 	return mmGet.mock
 }
 
-//Set uses given function f to mock the ICache.Get method
-func (mmGet *mICacheMockGet) Set(f func(key string) (p1 interface{}, b1 bool)) *ICacheMock {
+// Set uses given function f to mock the Cache.Get method
+func (mmGet *mCacheMockGet) Set(f func(key string) (p1 interface{}, b1 bool)) *CacheMock {
 	if mmGet.defaultExpectation != nil {
-		mmGet.mock.t.Fatalf("Default expectation is already set for the ICache.Get method")
+		mmGet.mock.t.Fatalf("Default expectation is already set for the Cache.Get method")
 	}
 
 	if len(mmGet.expectations) > 0 {
-		mmGet.mock.t.Fatalf("Some expectations are already set for the ICache.Get method")
+		mmGet.mock.t.Fatalf("Some expectations are already set for the Cache.Get method")
 	}
 
 	mmGet.mock.funcGet = f
 	return mmGet.mock
 }
 
-// When sets expectation for the ICache.Get which will trigger the result defined by the following
+// When sets expectation for the Cache.Get which will trigger the result defined by the following
 // Then helper
-func (mmGet *mICacheMockGet) When(key string) *ICacheMockGetExpectation {
+func (mmGet *mCacheMockGet) When(key string) *CacheMockGetExpectation {
 	if mmGet.mock.funcGet != nil {
-		mmGet.mock.t.Fatalf("ICacheMock.Get mock is already set by Set")
+		mmGet.mock.t.Fatalf("CacheMock.Get mock is already set by Set")
 	}
 
-	expectation := &ICacheMockGetExpectation{
+	expectation := &CacheMockGetExpectation{
 		mock:   mmGet.mock,
-		params: &ICacheMockGetParams{key},
+		params: &CacheMockGetParams{key},
 	}
 	mmGet.expectations = append(mmGet.expectations, expectation)
 	return expectation
 }
 
-// Then sets up ICache.Get return parameters for the expectation previously defined by the When method
-func (e *ICacheMockGetExpectation) Then(p1 interface{}, b1 bool) *ICacheMock {
-	e.results = &ICacheMockGetResults{p1, b1}
+// Then sets up Cache.Get return parameters for the expectation previously defined by the When method
+func (e *CacheMockGetExpectation) Then(p1 interface{}, b1 bool) *CacheMock {
+	e.results = &CacheMockGetResults{p1, b1}
 	return e.mock
 }
 
-// Get implements interfaces.ICache
-func (mmGet *ICacheMock) Get(key string) (p1 interface{}, b1 bool) {
+// Get implements interfaces.Cache
+func (mmGet *CacheMock) Get(key string) (p1 interface{}, b1 bool) {
 	mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
 	defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)
 
@@ -304,7 +304,7 @@ func (mmGet *ICacheMock) Get(key string) (p1 interface{}, b1 bool) {
 		mmGet.inspectFuncGet(key)
 	}
 
-	mm_params := &ICacheMockGetParams{key}
+	mm_params := &CacheMockGetParams{key}
 
 	// Record call args
 	mmGet.GetMock.mutex.Lock()
@@ -321,40 +321,40 @@ func (mmGet *ICacheMock) Get(key string) (p1 interface{}, b1 bool) {
 	if mmGet.GetMock.defaultExpectation != nil {
 		mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
 		mm_want := mmGet.GetMock.defaultExpectation.params
-		mm_got := ICacheMockGetParams{key}
+		mm_got := CacheMockGetParams{key}
 		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmGet.t.Errorf("ICacheMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
+			mmGet.t.Errorf("CacheMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
 		}
 
 		mm_results := mmGet.GetMock.defaultExpectation.results
 		if mm_results == nil {
-			mmGet.t.Fatal("No results are set for the ICacheMock.Get")
+			mmGet.t.Fatal("No results are set for the CacheMock.Get")
 		}
 		return (*mm_results).p1, (*mm_results).b1
 	}
 	if mmGet.funcGet != nil {
 		return mmGet.funcGet(key)
 	}
-	mmGet.t.Fatalf("Unexpected call to ICacheMock.Get. %v", key)
+	mmGet.t.Fatalf("Unexpected call to CacheMock.Get. %v", key)
 	return
 }
 
-// GetAfterCounter returns a count of finished ICacheMock.Get invocations
-func (mmGet *ICacheMock) GetAfterCounter() uint64 {
+// GetAfterCounter returns a count of finished CacheMock.Get invocations
+func (mmGet *CacheMock) GetAfterCounter() uint64 {
 	return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
 }
 
-// GetBeforeCounter returns a count of ICacheMock.Get invocations
-func (mmGet *ICacheMock) GetBeforeCounter() uint64 {
+// GetBeforeCounter returns a count of CacheMock.Get invocations
+func (mmGet *CacheMock) GetBeforeCounter() uint64 {
 	return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
 }
 
-// Calls returns a list of arguments used in each call to ICacheMock.Get.
+// Calls returns a list of arguments used in each call to CacheMock.Get.
 // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmGet *mICacheMockGet) Calls() []*ICacheMockGetParams {
+func (mmGet *mCacheMockGet) Calls() []*CacheMockGetParams {
 	mmGet.mutex.RLock()
 
-	argCopy := make([]*ICacheMockGetParams, len(mmGet.callArgs))
+	argCopy := make([]*CacheMockGetParams, len(mmGet.callArgs))
 	copy(argCopy, mmGet.callArgs)
 
 	mmGet.mutex.RUnlock()
@@ -364,7 +364,7 @@ func (mmGet *mICacheMockGet) Calls() []*ICacheMockGetParams {
 
 // MinimockGetDone returns true if the count of the Get invocations corresponds
 // the number of defined expectations
-func (m *ICacheMock) MinimockGetDone() bool {
+func (m *CacheMock) MinimockGetDone() bool {
 	for _, e := range m.GetMock.expectations {
 		if mm_atomic.LoadUint64(&e.Counter) < 1 {
 			return false
@@ -383,61 +383,61 @@ func (m *ICacheMock) MinimockGetDone() bool {
 }
 
 // MinimockGetInspect logs each unmet expectation
-func (m *ICacheMock) MinimockGetInspect() {
+func (m *CacheMock) MinimockGetInspect() {
 	for _, e := range m.GetMock.expectations {
 		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to ICacheMock.Get with params: %#v", *e.params)
+			m.t.Errorf("Expected call to CacheMock.Get with params: %#v", *e.params)
 		}
 	}
 
 	// if default expectation was set then invocations count should be greater than zero
 	if m.GetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
 		if m.GetMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to ICacheMock.Get")
+			m.t.Error("Expected call to CacheMock.Get")
 		} else {
-			m.t.Errorf("Expected call to ICacheMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
+			m.t.Errorf("Expected call to CacheMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
 		}
 	}
 	// if func was set then invocations count should be greater than zero
 	if m.funcGet != nil && mm_atomic.LoadUint64(&m.afterGetCounter) < 1 {
-		m.t.Error("Expected call to ICacheMock.Get")
+		m.t.Error("Expected call to CacheMock.Get")
 	}
 }
 
-type mICacheMockSet struct {
-	mock               *ICacheMock
-	defaultExpectation *ICacheMockSetExpectation
-	expectations       []*ICacheMockSetExpectation
+type mCacheMockSet struct {
+	mock               *CacheMock
+	defaultExpectation *CacheMockSetExpectation
+	expectations       []*CacheMockSetExpectation
 
-	callArgs []*ICacheMockSetParams
+	callArgs []*CacheMockSetParams
 	mutex    sync.RWMutex
 }
 
-// ICacheMockSetExpectation specifies expectation struct of the ICache.Set
-type ICacheMockSetExpectation struct {
-	mock   *ICacheMock
-	params *ICacheMockSetParams
+// CacheMockSetExpectation specifies expectation struct of the Cache.Set
+type CacheMockSetExpectation struct {
+	mock   *CacheMock
+	params *CacheMockSetParams
 
 	Counter uint64
 }
 
-// ICacheMockSetParams contains parameters of the ICache.Set
-type ICacheMockSetParams struct {
+// CacheMockSetParams contains parameters of the Cache.Set
+type CacheMockSetParams struct {
 	key   string
 	value interface{}
 }
 
-// Expect sets up expected params for ICache.Set
-func (mmSet *mICacheMockSet) Expect(key string, value interface{}) *mICacheMockSet {
+// Expect sets up expected params for Cache.Set
+func (mmSet *mCacheMockSet) Expect(key string, value interface{}) *mCacheMockSet {
 	if mmSet.mock.funcSet != nil {
-		mmSet.mock.t.Fatalf("ICacheMock.Set mock is already set by Set")
+		mmSet.mock.t.Fatalf("CacheMock.Set mock is already set by Set")
 	}
 
 	if mmSet.defaultExpectation == nil {
-		mmSet.defaultExpectation = &ICacheMockSetExpectation{}
+		mmSet.defaultExpectation = &CacheMockSetExpectation{}
 	}
 
-	mmSet.defaultExpectation.params = &ICacheMockSetParams{key, value}
+	mmSet.defaultExpectation.params = &CacheMockSetParams{key, value}
 	for _, e := range mmSet.expectations {
 		if minimock.Equal(e.params, mmSet.defaultExpectation.params) {
 			mmSet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSet.defaultExpectation.params)
@@ -447,10 +447,10 @@ func (mmSet *mICacheMockSet) Expect(key string, value interface{}) *mICacheMockS
 	return mmSet
 }
 
-// Inspect accepts an inspector function that has same arguments as the ICache.Set
-func (mmSet *mICacheMockSet) Inspect(f func(key string, value interface{})) *mICacheMockSet {
+// Inspect accepts an inspector function that has same arguments as the Cache.Set
+func (mmSet *mCacheMockSet) Inspect(f func(key string, value interface{})) *mCacheMockSet {
 	if mmSet.mock.inspectFuncSet != nil {
-		mmSet.mock.t.Fatalf("Inspect function is already set for ICacheMock.Set")
+		mmSet.mock.t.Fatalf("Inspect function is already set for CacheMock.Set")
 	}
 
 	mmSet.mock.inspectFuncSet = f
@@ -458,35 +458,35 @@ func (mmSet *mICacheMockSet) Inspect(f func(key string, value interface{})) *mIC
 	return mmSet
 }
 
-// Return sets up results that will be returned by ICache.Set
-func (mmSet *mICacheMockSet) Return() *ICacheMock {
+// Return sets up results that will be returned by Cache.Set
+func (mmSet *mCacheMockSet) Return() *CacheMock {
 	if mmSet.mock.funcSet != nil {
-		mmSet.mock.t.Fatalf("ICacheMock.Set mock is already set by Set")
+		mmSet.mock.t.Fatalf("CacheMock.Set mock is already set by Set")
 	}
 
 	if mmSet.defaultExpectation == nil {
-		mmSet.defaultExpectation = &ICacheMockSetExpectation{mock: mmSet.mock}
+		mmSet.defaultExpectation = &CacheMockSetExpectation{mock: mmSet.mock}
 	}
 
 	return mmSet.mock
 }
 
-//Set uses given function f to mock the ICache.Set method
-func (mmSet *mICacheMockSet) Set(f func(key string, value interface{})) *ICacheMock {
+// Set uses given function f to mock the Cache.Set method
+func (mmSet *mCacheMockSet) Set(f func(key string, value interface{})) *CacheMock {
 	if mmSet.defaultExpectation != nil {
-		mmSet.mock.t.Fatalf("Default expectation is already set for the ICache.Set method")
+		mmSet.mock.t.Fatalf("Default expectation is already set for the Cache.Set method")
 	}
 
 	if len(mmSet.expectations) > 0 {
-		mmSet.mock.t.Fatalf("Some expectations are already set for the ICache.Set method")
+		mmSet.mock.t.Fatalf("Some expectations are already set for the Cache.Set method")
 	}
 
 	mmSet.mock.funcSet = f
 	return mmSet.mock
 }
 
-// Set implements interfaces.ICache
-func (mmSet *ICacheMock) Set(key string, value interface{}) {
+// Set implements interfaces.Cache
+func (mmSet *CacheMock) Set(key string, value interface{}) {
 	mm_atomic.AddUint64(&mmSet.beforeSetCounter, 1)
 	defer mm_atomic.AddUint64(&mmSet.afterSetCounter, 1)
 
@@ -494,7 +494,7 @@ func (mmSet *ICacheMock) Set(key string, value interface{}) {
 		mmSet.inspectFuncSet(key, value)
 	}
 
-	mm_params := &ICacheMockSetParams{key, value}
+	mm_params := &CacheMockSetParams{key, value}
 
 	// Record call args
 	mmSet.SetMock.mutex.Lock()
@@ -511,9 +511,9 @@ func (mmSet *ICacheMock) Set(key string, value interface{}) {
 	if mmSet.SetMock.defaultExpectation != nil {
 		mm_atomic.AddUint64(&mmSet.SetMock.defaultExpectation.Counter, 1)
 		mm_want := mmSet.SetMock.defaultExpectation.params
-		mm_got := ICacheMockSetParams{key, value}
+		mm_got := CacheMockSetParams{key, value}
 		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmSet.t.Errorf("ICacheMock.Set got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
+			mmSet.t.Errorf("CacheMock.Set got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
 		}
 
 		return
@@ -523,26 +523,26 @@ func (mmSet *ICacheMock) Set(key string, value interface{}) {
 		mmSet.funcSet(key, value)
 		return
 	}
-	mmSet.t.Fatalf("Unexpected call to ICacheMock.Set. %v %v", key, value)
+	mmSet.t.Fatalf("Unexpected call to CacheMock.Set. %v %v", key, value)
 
 }
 
-// SetAfterCounter returns a count of finished ICacheMock.Set invocations
-func (mmSet *ICacheMock) SetAfterCounter() uint64 {
+// SetAfterCounter returns a count of finished CacheMock.Set invocations
+func (mmSet *CacheMock) SetAfterCounter() uint64 {
 	return mm_atomic.LoadUint64(&mmSet.afterSetCounter)
 }
 
-// SetBeforeCounter returns a count of ICacheMock.Set invocations
-func (mmSet *ICacheMock) SetBeforeCounter() uint64 {
+// SetBeforeCounter returns a count of CacheMock.Set invocations
+func (mmSet *CacheMock) SetBeforeCounter() uint64 {
 	return mm_atomic.LoadUint64(&mmSet.beforeSetCounter)
 }
 
-// Calls returns a list of arguments used in each call to ICacheMock.Set.
+// Calls returns a list of arguments used in each call to CacheMock.Set.
 // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmSet *mICacheMockSet) Calls() []*ICacheMockSetParams {
+func (mmSet *mCacheMockSet) Calls() []*CacheMockSetParams {
 	mmSet.mutex.RLock()
 
-	argCopy := make([]*ICacheMockSetParams, len(mmSet.callArgs))
+	argCopy := make([]*CacheMockSetParams, len(mmSet.callArgs))
 	copy(argCopy, mmSet.callArgs)
 
 	mmSet.mutex.RUnlock()
@@ -552,7 +552,7 @@ func (mmSet *mICacheMockSet) Calls() []*ICacheMockSetParams {
 
 // MinimockSetDone returns true if the count of the Set invocations corresponds
 // the number of defined expectations
-func (m *ICacheMock) MinimockSetDone() bool {
+func (m *CacheMock) MinimockSetDone() bool {
 	for _, e := range m.SetMock.expectations {
 		if mm_atomic.LoadUint64(&e.Counter) < 1 {
 			return false
@@ -571,29 +571,29 @@ func (m *ICacheMock) MinimockSetDone() bool {
 }
 
 // MinimockSetInspect logs each unmet expectation
-func (m *ICacheMock) MinimockSetInspect() {
+func (m *CacheMock) MinimockSetInspect() {
 	for _, e := range m.SetMock.expectations {
 		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to ICacheMock.Set with params: %#v", *e.params)
+			m.t.Errorf("Expected call to CacheMock.Set with params: %#v", *e.params)
 		}
 	}
 
 	// if default expectation was set then invocations count should be greater than zero
 	if m.SetMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSetCounter) < 1 {
 		if m.SetMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to ICacheMock.Set")
+			m.t.Error("Expected call to CacheMock.Set")
 		} else {
-			m.t.Errorf("Expected call to ICacheMock.Set with params: %#v", *m.SetMock.defaultExpectation.params)
+			m.t.Errorf("Expected call to CacheMock.Set with params: %#v", *m.SetMock.defaultExpectation.params)
 		}
 	}
 	// if func was set then invocations count should be greater than zero
 	if m.funcSet != nil && mm_atomic.LoadUint64(&m.afterSetCounter) < 1 {
-		m.t.Error("Expected call to ICacheMock.Set")
+		m.t.Error("Expected call to CacheMock.Set")
 	}
 }
 
 // MinimockFinish checks that all mocked methods have been called the expected number of times
-func (m *ICacheMock) MinimockFinish() {
+func (m *CacheMock) MinimockFinish() {
 	if !m.minimockDone() {
 		m.MinimockFlushAllInspect()
 
@@ -605,7 +605,7 @@ func (m *ICacheMock) MinimockFinish() {
 }
 
 // MinimockWait waits for all mocked methods to be called the expected number of times
-func (m *ICacheMock) MinimockWait(timeout mm_time.Duration) {
+func (m *CacheMock) MinimockWait(timeout mm_time.Duration) {
 	timeoutCh := mm_time.After(timeout)
 	for {
 		if m.minimockDone() {
@@ -620,7 +620,7 @@ func (m *ICacheMock) MinimockWait(timeout mm_time.Duration) {
 	}
 }
 
-func (m *ICacheMock) minimockDone() bool {
+func (m *CacheMock) minimockDone() bool {
 	done := true
 	return done &&
 		m.MinimockFlushAllDone() &&

+ 25 - 4
internal/services/db/db.go

@@ -2,19 +2,40 @@ package db
 
 import (
 	"database/sql"
+	"time"
 
 	"github.com/dmitriygnatenko/internal/interfaces"
 )
 
-func Init(env interfaces.IEnv) (*sql.DB, error) {
-	dataSource := env.GetDBUser() + ":" + env.GetDBPassword() +
-		"@tcp(" + env.GetDBHost() + ":" + env.GetDBPort() + ")/" + env.GetDBName()
+func Init(env interfaces.Env) (*sql.DB, error) {
+	dataSource := "user=" + env.GetDBUser() +
+		" password=" + env.GetDBPassword() +
+		" dbname=" + env.GetDBName() +
+		" host=" + env.GetDBHost() +
+		" port=" + env.GetDBPort() +
+		" sslmode=disable"
 
-	db, err := sql.Open("mysql", dataSource)
+	db, err := sql.Open("postgres", dataSource)
 	if err != nil {
 		return nil, err
 	}
 
+	if env.GetDBMaxOpenConns() > 0 {
+		db.SetMaxOpenConns(env.GetDBMaxOpenConns())
+	}
+
+	if env.GetDBMaxIdleConns() > 0 {
+		db.SetMaxIdleConns(env.GetDBMaxIdleConns())
+	}
+
+	if env.GetDBMaxConnLifetime() > 0 {
+		db.SetConnMaxLifetime(time.Second * time.Duration(env.GetDBMaxConnLifetime()))
+	}
+
+	if env.GetDBMaxIdleConnLifetime() > 0 {
+		db.SetConnMaxIdleTime(time.Second * time.Duration(env.GetDBMaxIdleConnLifetime()))
+	}
+
 	if err = db.Ping(); err != nil {
 		return nil, err
 	}

+ 91 - 125
internal/services/env/env.go

@@ -1,194 +1,160 @@
 package env
 
 import (
-	"bufio"
 	"flag"
-	"os"
-	"strings"
 
 	"github.com/dmitriygnatenko/internal/interfaces"
+	"github.com/spf13/viper"
 )
 
-// nolint:gosec
-const (
-	envPath = "../../config/.env"
+const defaultConfigPath = "../../.env"
 
-	appPortEnv = "APP_PORT"
+type env struct {
+	AppPort string `mapstructure:"APP_PORT"`
 
-	dbHostEnv     = "DB_HOST"
-	dbPortEnv     = "DB_PORT"
-	dbNameEnv     = "DB_NAME"
-	dbUserEnv     = "DB_USER"
-	dbPasswordEnv = "DB_PASSWORD"
+	DBHost     string `mapstructure:"DB_HOST"`
+	DBPort     string `mapstructure:"DB_PORT"`
+	DBName     string `mapstructure:"DB_NAME"`
+	DBUser     string `mapstructure:"DB_USER"`
+	DBPassword string `mapstructure:"DB_PASSWORD"`
 
-	smtpHostEnv     = "SMTP_HOST"
-	smtpPortEnv     = "SMTP_PORT"
-	smtpUserEnv     = "SMTP_USER"
-	smtpPasswordEnv = "SMTP_PASSWORD"
+	DBMaxOpenConns        int `mapstructure:"DB_MAX_OPEN_CONNS"`
+	DBMaxIdleConns        int `mapstructure:"DB_MAX_IDLE_CONNS"`
+	DBMaxConnLifetime     int `mapstructure:"DB_MAX_CONN_LIFETIME"`
+	DBMaxIdleConnLifetime int `mapstructure:"DB_MAX_IDLE_CONN_LIFETIME"`
 
-	staticVersionEnv = "STATIC_VERSION"
-	gaEnabledEnv     = "GA_ENABLED"
+	CORSAllowOrigins string `mapstructure:"CORS_ALLOW_ORIGING"`
+	CORSAllowMethods string `mapstructure:"CORS_ALLOW_METHODS"`
 
-	adminEmailEnv    = "ADMIN_EMAIL"
-	adminUserEnv     = "ADMIN_USER"
-	adminPasswordEnv = "ADMIN_PASSWORD"
-)
+	JWTSecretKey string `mapstructure:"JWT_SECRET_KEY"`
+	JWTLifeTime  int    `mapstructure:"JWT_LIFETIME"`
 
-type env struct {
-	appPort string
+	BasicAuthUser     string `mapstructure:"BASIC_AUTH_USER"`
+	BasicAuthPassword string `mapstructure:"BASIC_AUTH_PASSWORD"`
 
-	dbHost     string
-	dbPort     string
-	dbName     string
-	dbUser     string
-	dbPassword string
+	SMTPHost     string `mapstructure:"SMTP_HOST"`
+	SMTPPort     string `mapstructure:"SMTP_PORT"`
+	SMTPUser     string `mapstructure:"SMTP_USER"`
+	SMTPPassword string `mapstructure:"SMTP_PASSWORD"`
 
-	smtpHost     string
-	smtpPort     string
-	smtpUser     string
-	smtpPassword string
+	ErrorsEmail string `mapstructure:"ERRORS_EMAIL"`
 
-	staticVersion string
-	gaEnabled     bool
+	GAKey string `mapstructure:"GA_KEY"`
 
-	adminEmail    string
-	adminUser     string
-	adminPassword string
+	StaticVersion int `mapstructure:"STATIC_VERSION"`
 }
 
-func Init() (interfaces.IEnv, error) {
-	res := &env{}
-
-	path := flag.String("config", envPath, "path to .env config")
+func Init() (interfaces.Env, error) {
+	var configPath string
+	flag.StringVar(&configPath, "config", "", "Path to .env config file")
 	flag.Parse()
 
-	file, err := os.Open(*path)
-	if err != nil {
-		return nil, err
+	if configPath == "" {
+		configPath = defaultConfigPath
 	}
-	defer file.Close()
-
-	scanner := bufio.NewScanner(file)
-	for scanner.Scan() {
-		line := strings.TrimSpace(scanner.Text())
-		if line == "" {
-			continue
-		}
 
-		if strings.HasPrefix(line, "#") {
-			continue
-		}
+	viper.SetConfigFile(configPath)
+	viper.SetConfigType("env")
+	viper.AutomaticEnv()
 
-		parts := strings.Split(line, "=")
-		if len(parts) < 2 {
-			continue
-		}
-
-		set(res, parts[0], parts[1])
-	}
-
-	if err = scanner.Err(); err != nil {
+	if err := viper.ReadInConfig(); err != nil {
 		return nil, err
 	}
 
-	return res, err
-}
+	res := &env{}
+	err := viper.Unmarshal(&res)
 
-func set(res *env, key string, value string) {
-	switch key {
-	case appPortEnv:
-		res.appPort = value
-
-	case dbHostEnv:
-		res.dbHost = value
-	case dbPortEnv:
-		res.dbPort = value
-	case dbNameEnv:
-		res.dbName = value
-	case dbUserEnv:
-		res.dbUser = value
-	case dbPasswordEnv:
-		res.dbPassword = value
-
-	case smtpPortEnv:
-		res.smtpPort = value
-	case smtpHostEnv:
-		res.smtpHost = value
-	case smtpUserEnv:
-		res.smtpUser = value
-	case smtpPasswordEnv:
-		res.smtpPassword = value
-
-	case staticVersionEnv:
-		res.staticVersion = value
-	case gaEnabledEnv:
-		res.gaEnabled = value == "true"
-
-	case adminEmailEnv:
-		res.adminEmail = value
-	case adminUserEnv:
-		res.adminUser = value
-	case adminPasswordEnv:
-		res.adminPassword = value
-	}
+	return res, err
 }
 
 func (e *env) GetAppPort() string {
-	return e.appPort
+	return e.AppPort
 }
 
 func (e *env) GetDBHost() string {
-	return e.dbHost
+	return e.DBHost
 }
 
 func (e *env) GetDBPort() string {
-	return e.dbPort
+	return e.DBPort
 }
 
 func (e *env) GetDBName() string {
-	return e.dbName
+	return e.DBName
 }
 
 func (e *env) GetDBUser() string {
-	return e.dbUser
+	return e.DBUser
 }
 
 func (e *env) GetDBPassword() string {
-	return e.dbPassword
+	return e.DBPassword
 }
 
-func (e *env) GetSMTPPort() string {
-	return e.smtpPort
+func (e *env) GetCORSAllowOrigins() string {
+	return e.CORSAllowOrigins
+}
+
+func (e *env) GetCORSAllowMethods() string {
+	return e.CORSAllowMethods
+}
+
+func (e *env) GetDBMaxOpenConns() int {
+	return e.DBMaxOpenConns
+}
+
+func (e *env) GetDBMaxIdleConns() int {
+	return e.DBMaxIdleConns
+}
+
+func (e *env) GetDBMaxConnLifetime() int {
+	return e.DBMaxConnLifetime
+}
+
+func (e *env) GetDBMaxIdleConnLifetime() int {
+	return e.DBMaxIdleConnLifetime
 }
 
 func (e *env) GetSMTPHost() string {
-	return e.smtpHost
+	return e.SMTPHost
+}
+
+func (e *env) GetSMTPPort() string {
+	return e.SMTPPort
 }
 
 func (e *env) GetSMTPUser() string {
-	return e.smtpUser
+	return e.SMTPUser
 }
 
 func (e *env) GetSMTPPassword() string {
-	return e.smtpPassword
+	return e.SMTPPassword
+}
+
+func (e *env) GetJWTSecretKey() string {
+	return e.JWTSecretKey
+}
+
+func (e *env) GetJWTLifetime() int {
+	return e.JWTLifeTime
 }
 
-func (e *env) GetStaticVersion() string {
-	return e.staticVersion
+func (e *env) GetErrorsEmail() string {
+	return e.ErrorsEmail
 }
 
-func (e *env) IsGAEnabled() bool {
-	return e.gaEnabled
+func (e *env) GetBasicAuthUser() string {
+	return e.BasicAuthUser
 }
 
-func (e *env) GetAdminEmail() string {
-	return e.adminEmail
+func (e *env) GetBasicAuthPassword() string {
+	return e.BasicAuthPassword
 }
 
-func (e *env) GetAdminUser() string {
-	return e.adminUser
+func (e *env) GetStaticVersion() int {
+	return e.StaticVersion
 }
 
-func (e *env) GetAdminPassword() string {
-	return e.adminPassword
+func (e *env) GetGAKey() string {
+	return e.GAKey
 }

+ 4 - 4
internal/services/mailer/mailer.go

@@ -2,7 +2,7 @@ package mailer
 
 //go:generate mkdir -p mocks
 //go:generate rm -rf ./mocks/*_minimock.go
-//go:generate minimock -i github.com/dmitriygnatenko/internal/interfaces.IMailer -o ./mocks/ -s "_minimock.go"
+//go:generate minimock -i github.com/dmitriygnatenko/internal/interfaces.Mailer -o ./mocks/ -s "_minimock.go"
 
 import (
 	"fmt"
@@ -25,14 +25,14 @@ type mailerAuth struct {
 	password string
 }
 
-func Init(env interfaces.IEnv) interfaces.IMailer {
+func Init(env interfaces.Env) (interfaces.Mailer, error) {
 	host := strings.TrimSpace(env.GetSMTPHost())
 	port := strings.TrimSpace(env.GetSMTPPort())
 	user := strings.TrimSpace(env.GetSMTPUser())
 	password := strings.TrimSpace(env.GetSMTPPassword())
 
 	if host == "" || port == "" || user == "" || password == "" {
-		return &mailer{}
+		return &mailer{}, nil
 	}
 
 	return &mailer{
@@ -41,7 +41,7 @@ func Init(env interfaces.IEnv) interfaces.IMailer {
 		port:      port,
 		user:      user,
 		password:  password,
-	}
+	}, nil
 }
 
 func (m mailer) Send(recipient string, subject string, text string) error {

+ 71 - 71
internal/services/mailer/mocks/i_mailer_minimock.go → internal/services/mailer/mocks/mailer_minimock.go

@@ -2,7 +2,7 @@ package mocks
 
 // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
 
-//go:generate minimock -i github.com/dmitriygnatenko/internal/interfaces.IMailer -o ./mocks/i_mailer_minimock.go -n IMailerMock
+//go:generate minimock -i github.com/dmitriygnatenko/internal/interfaces.Mailer -o ./mocks/mailer_minimock.go -n MailerMock
 
 import (
 	"sync"
@@ -12,70 +12,70 @@ import (
 	"github.com/gojuno/minimock/v3"
 )
 
-// IMailerMock implements interfaces.IMailer
-type IMailerMock struct {
+// MailerMock implements interfaces.Mailer
+type MailerMock struct {
 	t minimock.Tester
 
 	funcSend          func(recipient string, subject string, text string) (err error)
 	inspectFuncSend   func(recipient string, subject string, text string)
 	afterSendCounter  uint64
 	beforeSendCounter uint64
-	SendMock          mIMailerMockSend
+	SendMock          mMailerMockSend
 }
 
-// NewIMailerMock returns a mock for interfaces.IMailer
-func NewIMailerMock(t minimock.Tester) *IMailerMock {
-	m := &IMailerMock{t: t}
+// NewMailerMock returns a mock for interfaces.Mailer
+func NewMailerMock(t minimock.Tester) *MailerMock {
+	m := &MailerMock{t: t}
 	if controller, ok := t.(minimock.MockController); ok {
 		controller.RegisterMocker(m)
 	}
 
-	m.SendMock = mIMailerMockSend{mock: m}
-	m.SendMock.callArgs = []*IMailerMockSendParams{}
+	m.SendMock = mMailerMockSend{mock: m}
+	m.SendMock.callArgs = []*MailerMockSendParams{}
 
 	return m
 }
 
-type mIMailerMockSend struct {
-	mock               *IMailerMock
-	defaultExpectation *IMailerMockSendExpectation
-	expectations       []*IMailerMockSendExpectation
+type mMailerMockSend struct {
+	mock               *MailerMock
+	defaultExpectation *MailerMockSendExpectation
+	expectations       []*MailerMockSendExpectation
 
-	callArgs []*IMailerMockSendParams
+	callArgs []*MailerMockSendParams
 	mutex    sync.RWMutex
 }
 
-// IMailerMockSendExpectation specifies expectation struct of the IMailer.Send
-type IMailerMockSendExpectation struct {
-	mock    *IMailerMock
-	params  *IMailerMockSendParams
-	results *IMailerMockSendResults
+// MailerMockSendExpectation specifies expectation struct of the Mailer.Send
+type MailerMockSendExpectation struct {
+	mock    *MailerMock
+	params  *MailerMockSendParams
+	results *MailerMockSendResults
 	Counter uint64
 }
 
-// IMailerMockSendParams contains parameters of the IMailer.Send
-type IMailerMockSendParams struct {
+// MailerMockSendParams contains parameters of the Mailer.Send
+type MailerMockSendParams struct {
 	recipient string
 	subject   string
 	text      string
 }
 
-// IMailerMockSendResults contains results of the IMailer.Send
-type IMailerMockSendResults struct {
+// MailerMockSendResults contains results of the Mailer.Send
+type MailerMockSendResults struct {
 	err error
 }
 
-// Expect sets up expected params for IMailer.Send
-func (mmSend *mIMailerMockSend) Expect(recipient string, subject string, text string) *mIMailerMockSend {
+// Expect sets up expected params for Mailer.Send
+func (mmSend *mMailerMockSend) Expect(recipient string, subject string, text string) *mMailerMockSend {
 	if mmSend.mock.funcSend != nil {
-		mmSend.mock.t.Fatalf("IMailerMock.Send mock is already set by Set")
+		mmSend.mock.t.Fatalf("MailerMock.Send mock is already set by Set")
 	}
 
 	if mmSend.defaultExpectation == nil {
-		mmSend.defaultExpectation = &IMailerMockSendExpectation{}
+		mmSend.defaultExpectation = &MailerMockSendExpectation{}
 	}
 
-	mmSend.defaultExpectation.params = &IMailerMockSendParams{recipient, subject, text}
+	mmSend.defaultExpectation.params = &MailerMockSendParams{recipient, subject, text}
 	for _, e := range mmSend.expectations {
 		if minimock.Equal(e.params, mmSend.defaultExpectation.params) {
 			mmSend.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSend.defaultExpectation.params)
@@ -85,10 +85,10 @@ func (mmSend *mIMailerMockSend) Expect(recipient string, subject string, text st
 	return mmSend
 }
 
-// Inspect accepts an inspector function that has same arguments as the IMailer.Send
-func (mmSend *mIMailerMockSend) Inspect(f func(recipient string, subject string, text string)) *mIMailerMockSend {
+// Inspect accepts an inspector function that has same arguments as the Mailer.Send
+func (mmSend *mMailerMockSend) Inspect(f func(recipient string, subject string, text string)) *mMailerMockSend {
 	if mmSend.mock.inspectFuncSend != nil {
-		mmSend.mock.t.Fatalf("Inspect function is already set for IMailerMock.Send")
+		mmSend.mock.t.Fatalf("Inspect function is already set for MailerMock.Send")
 	}
 
 	mmSend.mock.inspectFuncSend = f
@@ -96,56 +96,56 @@ func (mmSend *mIMailerMockSend) Inspect(f func(recipient string, subject string,
 	return mmSend
 }
 
-// Return sets up results that will be returned by IMailer.Send
-func (mmSend *mIMailerMockSend) Return(err error) *IMailerMock {
+// Return sets up results that will be returned by Mailer.Send
+func (mmSend *mMailerMockSend) Return(err error) *MailerMock {
 	if mmSend.mock.funcSend != nil {
-		mmSend.mock.t.Fatalf("IMailerMock.Send mock is already set by Set")
+		mmSend.mock.t.Fatalf("MailerMock.Send mock is already set by Set")
 	}
 
 	if mmSend.defaultExpectation == nil {
-		mmSend.defaultExpectation = &IMailerMockSendExpectation{mock: mmSend.mock}
+		mmSend.defaultExpectation = &MailerMockSendExpectation{mock: mmSend.mock}
 	}
-	mmSend.defaultExpectation.results = &IMailerMockSendResults{err}
+	mmSend.defaultExpectation.results = &MailerMockSendResults{err}
 	return mmSend.mock
 }
 
-//Set uses given function f to mock the IMailer.Send method
-func (mmSend *mIMailerMockSend) Set(f func(recipient string, subject string, text string) (err error)) *IMailerMock {
+// Set uses given function f to mock the Mailer.Send method
+func (mmSend *mMailerMockSend) Set(f func(recipient string, subject string, text string) (err error)) *MailerMock {
 	if mmSend.defaultExpectation != nil {
-		mmSend.mock.t.Fatalf("Default expectation is already set for the IMailer.Send method")
+		mmSend.mock.t.Fatalf("Default expectation is already set for the Mailer.Send method")
 	}
 
 	if len(mmSend.expectations) > 0 {
-		mmSend.mock.t.Fatalf("Some expectations are already set for the IMailer.Send method")
+		mmSend.mock.t.Fatalf("Some expectations are already set for the Mailer.Send method")
 	}
 
 	mmSend.mock.funcSend = f
 	return mmSend.mock
 }
 
-// When sets expectation for the IMailer.Send which will trigger the result defined by the following
+// When sets expectation for the Mailer.Send which will trigger the result defined by the following
 // Then helper
-func (mmSend *mIMailerMockSend) When(recipient string, subject string, text string) *IMailerMockSendExpectation {
+func (mmSend *mMailerMockSend) When(recipient string, subject string, text string) *MailerMockSendExpectation {
 	if mmSend.mock.funcSend != nil {
-		mmSend.mock.t.Fatalf("IMailerMock.Send mock is already set by Set")
+		mmSend.mock.t.Fatalf("MailerMock.Send mock is already set by Set")
 	}
 
-	expectation := &IMailerMockSendExpectation{
+	expectation := &MailerMockSendExpectation{
 		mock:   mmSend.mock,
-		params: &IMailerMockSendParams{recipient, subject, text},
+		params: &MailerMockSendParams{recipient, subject, text},
 	}
 	mmSend.expectations = append(mmSend.expectations, expectation)
 	return expectation
 }
 
-// Then sets up IMailer.Send return parameters for the expectation previously defined by the When method
-func (e *IMailerMockSendExpectation) Then(err error) *IMailerMock {
-	e.results = &IMailerMockSendResults{err}
+// Then sets up Mailer.Send return parameters for the expectation previously defined by the When method
+func (e *MailerMockSendExpectation) Then(err error) *MailerMock {
+	e.results = &MailerMockSendResults{err}
 	return e.mock
 }
 
-// Send implements interfaces.IMailer
-func (mmSend *IMailerMock) Send(recipient string, subject string, text string) (err error) {
+// Send implements interfaces.Mailer
+func (mmSend *MailerMock) Send(recipient string, subject string, text string) (err error) {
 	mm_atomic.AddUint64(&mmSend.beforeSendCounter, 1)
 	defer mm_atomic.AddUint64(&mmSend.afterSendCounter, 1)
 
@@ -153,7 +153,7 @@ func (mmSend *IMailerMock) Send(recipient string, subject string, text string) (
 		mmSend.inspectFuncSend(recipient, subject, text)
 	}
 
-	mm_params := &IMailerMockSendParams{recipient, subject, text}
+	mm_params := &MailerMockSendParams{recipient, subject, text}
 
 	// Record call args
 	mmSend.SendMock.mutex.Lock()
@@ -170,40 +170,40 @@ func (mmSend *IMailerMock) Send(recipient string, subject string, text string) (
 	if mmSend.SendMock.defaultExpectation != nil {
 		mm_atomic.AddUint64(&mmSend.SendMock.defaultExpectation.Counter, 1)
 		mm_want := mmSend.SendMock.defaultExpectation.params
-		mm_got := IMailerMockSendParams{recipient, subject, text}
+		mm_got := MailerMockSendParams{recipient, subject, text}
 		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
-			mmSend.t.Errorf("IMailerMock.Send got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
+			mmSend.t.Errorf("MailerMock.Send got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
 		}
 
 		mm_results := mmSend.SendMock.defaultExpectation.results
 		if mm_results == nil {
-			mmSend.t.Fatal("No results are set for the IMailerMock.Send")
+			mmSend.t.Fatal("No results are set for the MailerMock.Send")
 		}
 		return (*mm_results).err
 	}
 	if mmSend.funcSend != nil {
 		return mmSend.funcSend(recipient, subject, text)
 	}
-	mmSend.t.Fatalf("Unexpected call to IMailerMock.Send. %v %v %v", recipient, subject, text)
+	mmSend.t.Fatalf("Unexpected call to MailerMock.Send. %v %v %v", recipient, subject, text)
 	return
 }
 
-// SendAfterCounter returns a count of finished IMailerMock.Send invocations
-func (mmSend *IMailerMock) SendAfterCounter() uint64 {
+// SendAfterCounter returns a count of finished MailerMock.Send invocations
+func (mmSend *MailerMock) SendAfterCounter() uint64 {
 	return mm_atomic.LoadUint64(&mmSend.afterSendCounter)
 }
 
-// SendBeforeCounter returns a count of IMailerMock.Send invocations
-func (mmSend *IMailerMock) SendBeforeCounter() uint64 {
+// SendBeforeCounter returns a count of MailerMock.Send invocations
+func (mmSend *MailerMock) SendBeforeCounter() uint64 {
 	return mm_atomic.LoadUint64(&mmSend.beforeSendCounter)
 }
 
-// Calls returns a list of arguments used in each call to IMailerMock.Send.
+// Calls returns a list of arguments used in each call to MailerMock.Send.
 // The list is in the same order as the calls were made (i.e. recent calls have a higher index)
-func (mmSend *mIMailerMockSend) Calls() []*IMailerMockSendParams {
+func (mmSend *mMailerMockSend) Calls() []*MailerMockSendParams {
 	mmSend.mutex.RLock()
 
-	argCopy := make([]*IMailerMockSendParams, len(mmSend.callArgs))
+	argCopy := make([]*MailerMockSendParams, len(mmSend.callArgs))
 	copy(argCopy, mmSend.callArgs)
 
 	mmSend.mutex.RUnlock()
@@ -213,7 +213,7 @@ func (mmSend *mIMailerMockSend) Calls() []*IMailerMockSendParams {
 
 // MinimockSendDone returns true if the count of the Send invocations corresponds
 // the number of defined expectations
-func (m *IMailerMock) MinimockSendDone() bool {
+func (m *MailerMock) MinimockSendDone() bool {
 	for _, e := range m.SendMock.expectations {
 		if mm_atomic.LoadUint64(&e.Counter) < 1 {
 			return false
@@ -232,29 +232,29 @@ func (m *IMailerMock) MinimockSendDone() bool {
 }
 
 // MinimockSendInspect logs each unmet expectation
-func (m *IMailerMock) MinimockSendInspect() {
+func (m *MailerMock) MinimockSendInspect() {
 	for _, e := range m.SendMock.expectations {
 		if mm_atomic.LoadUint64(&e.Counter) < 1 {
-			m.t.Errorf("Expected call to IMailerMock.Send with params: %#v", *e.params)
+			m.t.Errorf("Expected call to MailerMock.Send with params: %#v", *e.params)
 		}
 	}
 
 	// if default expectation was set then invocations count should be greater than zero
 	if m.SendMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSendCounter) < 1 {
 		if m.SendMock.defaultExpectation.params == nil {
-			m.t.Error("Expected call to IMailerMock.Send")
+			m.t.Error("Expected call to MailerMock.Send")
 		} else {
-			m.t.Errorf("Expected call to IMailerMock.Send with params: %#v", *m.SendMock.defaultExpectation.params)
+			m.t.Errorf("Expected call to MailerMock.Send with params: %#v", *m.SendMock.defaultExpectation.params)
 		}
 	}
 	// if func was set then invocations count should be greater than zero
 	if m.funcSend != nil && mm_atomic.LoadUint64(&m.afterSendCounter) < 1 {
-		m.t.Error("Expected call to IMailerMock.Send")
+		m.t.Error("Expected call to MailerMock.Send")
 	}
 }
 
 // MinimockFinish checks that all mocked methods have been called the expected number of times
-func (m *IMailerMock) MinimockFinish() {
+func (m *MailerMock) MinimockFinish() {
 	if !m.minimockDone() {
 		m.MinimockSendInspect()
 		m.t.FailNow()
@@ -262,7 +262,7 @@ func (m *IMailerMock) MinimockFinish() {
 }
 
 // MinimockWait waits for all mocked methods to be called the expected number of times
-func (m *IMailerMock) MinimockWait(timeout mm_time.Duration) {
+func (m *MailerMock) MinimockWait(timeout mm_time.Duration) {
 	timeoutCh := mm_time.After(timeout)
 	for {
 		if m.minimockDone() {
@@ -277,7 +277,7 @@ func (m *IMailerMock) MinimockWait(timeout mm_time.Duration) {
 	}
 }
 
-func (m *IMailerMock) minimockDone() bool {
+func (m *MailerMock) minimockDone() bool {
 	done := true
 	return done &&
 		m.MinimockSendDone()