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