feat(deps, server): add FileInfoStore to deps
This commit is contained in:
parent
e74c3c34e3
commit
a96f552323
4 changed files with 26 additions and 10 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"go.uber.org/zap"
|
||||
|
||||
"github.com/ihexxa/quickshare/src/cryptoutil"
|
||||
"github.com/ihexxa/quickshare/src/fileinfostore"
|
||||
"github.com/ihexxa/quickshare/src/fs"
|
||||
"github.com/ihexxa/quickshare/src/idgen"
|
||||
"github.com/ihexxa/quickshare/src/iolimiter"
|
||||
|
@ -25,6 +26,7 @@ type Deps struct {
|
|||
token cryptoutil.ITokenEncDec
|
||||
kv kvstore.IKVStore
|
||||
users userstore.IUserStore
|
||||
fileInfos fileinfostore.IFileInfoStore
|
||||
uploader IUploader
|
||||
id idgen.IIDGen
|
||||
logger *zap.SugaredLogger
|
||||
|
@ -83,6 +85,14 @@ func (deps *Deps) SetUsers(users userstore.IUserStore) {
|
|||
deps.users = users
|
||||
}
|
||||
|
||||
func (deps *Deps) FileInfos() fileinfostore.IFileInfoStore {
|
||||
return deps.fileInfos
|
||||
}
|
||||
|
||||
func (deps *Deps) SetFileInfos(fileInfos fileinfostore.IFileInfoStore) {
|
||||
deps.fileInfos = fileInfos
|
||||
}
|
||||
|
||||
func (deps *Deps) Limiter() iolimiter.ILimiter {
|
||||
return deps.limiter
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package userstore
|
||||
package fileinfostore
|
||||
|
||||
import (
|
||||
"github.com/ihexxa/quickshare/src/kvstore"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package userstore
|
||||
package fileinfostore
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
|
||||
"github.com/ihexxa/quickshare/src/cryptoutil/jwt"
|
||||
"github.com/ihexxa/quickshare/src/depidx"
|
||||
"github.com/ihexxa/quickshare/src/fileinfostore"
|
||||
"github.com/ihexxa/quickshare/src/fs"
|
||||
"github.com/ihexxa/quickshare/src/fs/local"
|
||||
"github.com/ihexxa/quickshare/src/handlers/fileshdr"
|
||||
|
@ -104,6 +105,10 @@ func initDeps(cfg gocfg.ICfg) *depidx.Deps {
|
|||
if err != nil {
|
||||
panic(fmt.Sprintf("fail to init user store: %s", err))
|
||||
}
|
||||
fileInfos, err := fileinfostore.NewFileInfoStore(kv)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("fail to init file info store: %s", err))
|
||||
}
|
||||
|
||||
limiterCap := cfg.IntOr("Users.LimiterCapacity", 10000)
|
||||
limiterCyc := cfg.IntOr("Users.LimiterCyc", 1000)
|
||||
|
@ -114,6 +119,7 @@ func initDeps(cfg gocfg.ICfg) *depidx.Deps {
|
|||
deps.SetToken(jwtEncDec)
|
||||
deps.SetKV(kv)
|
||||
deps.SetUsers(users)
|
||||
deps.SetFileInfos(fileInfos)
|
||||
deps.SetID(ider)
|
||||
deps.SetLog(logger)
|
||||
deps.SetLimiter(limiter)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue