-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpropsd.go
49 lines (42 loc) · 902 Bytes
/
propsd.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
49
package store
import (
"fmt"
"github.com/davepgreene/slackmac/propsd"
log "github.com/sirupsen/logrus"
"time"
)
type propsdStore struct {
client *propsd.Client
key string
}
// Get retrieves data from Propsd
func (p *propsdStore) Get() string {
resp, err := p.client.GetProperty(p.key)
if err != nil {
log.Error(err)
return ""
}
return string(resp)
}
func newPropsdStore(conf map[string]string) (Store, error) {
key, ok := conf["key"]
if !ok {
return nil, fmt.Errorf("%s is required for the propsd datastore", "key")
}
var endpoint string
endpoint, ok = conf["endpoint"]
if !ok {
endpoint = propsd.DefaultEndpoint
}
var timeout = propsd.DefaultTimeout
if timeoutStr, ok := conf["timeout"]; ok {
t, err := time.ParseDuration(timeoutStr)
if err == nil {
timeout = t
}
}
return &propsdStore{
client: propsd.NewClient(endpoint, timeout),
key: key,
}, nil
}