-
Notifications
You must be signed in to change notification settings - Fork 3
/
manager_factory.go
48 lines (38 loc) · 1.08 KB
/
manager_factory.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
38
39
40
41
42
43
44
45
46
47
48
package asc
import (
"github.com/viant/dsc"
"github.com/viant/toolbox"
)
const (
defaultTimeFormat = "yyyy-MM-dd HH:mm:ss z"
DateFormatKey = "dateFormat"
DateLayoutKey = "dateLayout"
)
type managerFactory struct{}
func (f *managerFactory) Create(config *dsc.Config) (dsc.Manager, error) {
if !config.Has(DateFormatKey) {
config.Parameters[DateFormatKey] = defaultTimeFormat
}
if !config.Has(DateLayoutKey) {
config.Parameters[DateLayoutKey] = toolbox.DateFormatToLayout(config.Get(DateFormatKey))
}
var connectionProvider = newConnectionProvider(config)
manager := &manager{}
var self dsc.Manager = manager
super := dsc.NewAbstractManager(config, connectionProvider, self)
manager.AbstractManager = super
var err error
manager.config, err = newConfig(config)
return self, err
}
func (f managerFactory) CreateFromURL(URL string) (dsc.Manager, error) {
config, err := dsc.NewConfigFromURL(URL)
if err != nil {
return nil, err
}
return f.Create(config)
}
func newManagerFactory() dsc.ManagerFactory {
var result dsc.ManagerFactory = &managerFactory{}
return result
}