-
Notifications
You must be signed in to change notification settings - Fork 13
/
uploader.go
36 lines (28 loc) · 957 Bytes
/
uploader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package registry
import (
"errors"
"github.com/coretrix/hitrix/service"
"github.com/coretrix/hitrix/service/component/uploader"
datastore "github.com/coretrix/hitrix/service/component/uploader/data_store"
"github.com/coretrix/hitrix/service/component/uploader/locker"
"github.com/sarulabs/di"
tusd "github.com/tus/tusd/pkg/handler"
)
func ServiceProviderUploader(c tusd.Config, getStoreFunc datastore.GetStoreFunc, getLockerFunc locker.GetLockerFunc) *service.DefinitionGlobal {
return &service.DefinitionGlobal{
Name: service.UploaderService,
Build: func(ctn di.Container) (interface{}, error) {
composer := tusd.NewStoreComposer()
if getStoreFunc == nil {
panic(errors.New("missing get data store func"))
}
store := getStoreFunc(ctn)
store.UseIn(composer)
if getLockerFunc != nil {
composer.UseLocker(getLockerFunc(ctn))
}
c.StoreComposer = composer
return uploader.NewTUSDUploader(c), nil
},
}
}