This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
settings.go
154 lines (118 loc) · 3.56 KB
/
settings.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package utils
import (
"path/filepath"
"time"
"github.com/findy-network/findy-agent/method"
"github.com/golang/glog"
)
const HTTPReqTimeout = 1 * time.Minute
var Settings = &Hub{}
type Hub struct {
registerName string // name of the persistent register where agents and their wallets are stored
registerBackupName string // cloud agent register's (above, json) backup file
registerBackupInterval time.Duration // hours between backups
walletBackupPath string
walletBackupTime string
gRPCAdmin string
serviceName string // name of the this service which is used in URLs, etc.
hostAddr string // Ip host name of the server's host seen from internet
versionInfo string // Version number etc. in free format as a string
timeout time.Duration // timeout setting for http requests and connections
exportPath string // wallet export path
localTestMode bool // tells if are running unit tests, will be obsolete
didMethod method.Type // the DID method to use as a default
}
func (h *Hub) DIDMethod() method.Type {
return h.didMethod
}
func (h *Hub) SetDIDMethod(m method.Type) {
h.didMethod = m
}
func (h *Hub) GRPCAdmin() string {
return h.gRPCAdmin
}
func (h *Hub) SetGRPCAdmin(gRPCAdmin string) {
h.gRPCAdmin = gRPCAdmin
}
func (h *Hub) WalletBackupTime() string {
return h.walletBackupTime
}
func (h *Hub) SetWalletBackupTime(t string) {
h.walletBackupTime = t
}
func (h *Hub) WalletBackupPath() string {
return h.walletBackupPath
}
func (h *Hub) SetWalletBackupPath(path string) {
h.walletBackupPath = path
}
func (h *Hub) RegisterBackupName() string {
return h.registerBackupName
}
func (h *Hub) SetRegisterBackupName(name string) {
h.registerBackupName = name
}
func (h *Hub) RegisterBackupInterval() time.Duration {
return h.registerBackupInterval
}
func (h *Hub) SetRegisterBackupInterval(interval time.Duration) {
h.registerBackupInterval = interval
}
func (h *Hub) RegisterName() string {
return h.registerName
}
func (h *Hub) SetRegisterName(registerName string) {
h.registerName = registerName
}
func (h *Hub) LocalTestMode() bool {
return h.localTestMode
}
func (h *Hub) SetLocalTestMode(localTestMode bool) {
h.localTestMode = localTestMode
}
// SetTimeout sets the default timeout for HTTP and WS requests.
func (h *Hub) SetTimeout(to time.Duration) {
h.timeout = to
}
// SetServiceName sets the service name for a2a communication
func (h *Hub) SetServiceName(n string) {
h.serviceName = n
}
// ServiceName returns service name for a2a communication
func (h *Hub) ServiceName() string {
return h.serviceName
}
// SetVersionInfo sets current version info of this agency. The info is shown in
// the certain API calls like Ping.
func (h *Hub) SetVersionInfo(info string) {
h.versionInfo = info
}
// SetHostAddr sets current host name of this service agency. The host name is
// used in the URLs and endpoints.
func (h *Hub) SetHostAddr(ipName string) {
glog.V(4).Infoln("setting host addr:", ipName)
h.hostAddr = ipName
}
// SetExportPath sets path for wallet exports.
func (h *Hub) SetExportPath(exportPath string) {
h.exportPath = exportPath
}
func (h *Hub) HostAddr() string {
return h.hostAddr
}
func (h *Hub) VersionInfo() string {
return h.versionInfo
}
func (h *Hub) Timeout() time.Duration {
if h.timeout == 0 {
return HTTPReqTimeout
}
return h.timeout
}
func (h *Hub) ExportPath() string {
return h.exportPath
}
func (h *Hub) WalletExportPath(filename string) (exportPath, url string) {
return filepath.Join(h.exportPath, filename),
h.hostAddr + filepath.Join("/static", filename)
}