-
Notifications
You must be signed in to change notification settings - Fork 14
/
uploader.go
37 lines (29 loc) · 965 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
37
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 ServiceDefinitionUploader(c tusd.Config, getStoreFunc datastore.GetStoreFunc, getLockerFunc locker.GetLockerFunc) *service.Definition {
return &service.Definition{
Name: service.UploaderService,
Global: true,
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
},
}
}