Skip to content

Commit 560a005

Browse files
committed
multi: add time unit to time.Duration config items
This makes it more clear to the user what valid units are for any duration based config entries.
1 parent fd5a138 commit 560a005

File tree

4 files changed

+40
-30
lines changed

4 files changed

+40
-30
lines changed

proof/courier.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,19 +550,19 @@ type BackoffCfg struct {
550550

551551
// BackoffResetWait is the amount of time we'll wait before
552552
// resetting the backoff counter to its initial state.
553-
BackoffResetWait time.Duration `long:"backoffresetwait" description:"The amount of time to wait before resetting the backoff counter."`
553+
BackoffResetWait time.Duration `long:"backoffresetwait" description:"The amount of time to wait before resetting the backoff counter. Valid time units are {s, m, h}."`
554554

555555
// NumTries is the number of times we'll try to deliver the proof to the
556556
// receiver before the BackoffResetWait delay is enforced.
557557
NumTries int `long:"numtries" description:"The number of proof delivery attempts before the backoff counter is reset."`
558558

559559
// InitialBackoff is the initial backoff time we'll use to wait before
560560
// retrying to deliver the proof to the receiver.
561-
InitialBackoff time.Duration `long:"initialbackoff" description:"The initial backoff time to wait before retrying to deliver the proof to the receiver."`
561+
InitialBackoff time.Duration `long:"initialbackoff" description:"The initial backoff time to wait before retrying to deliver the proof to the receiver. Valid time units are {s, m, h}."`
562562

563563
// MaxBackoff is the maximum backoff time we'll use to wait before
564564
// retrying to deliver the proof to the receiver.
565-
MaxBackoff time.Duration `long:"maxbackoff" description:"The maximum backoff time to wait before retrying to deliver the proof to the receiver."`
565+
MaxBackoff time.Duration `long:"maxbackoff" description:"The maximum backoff time to wait before retrying to deliver the proof to the receiver. Valid time units are {s, m, h}."`
566566
}
567567

568568
// BackoffHandler is a handler for the backoff procedure.
@@ -755,7 +755,7 @@ func NewBackoffHandler(cfg *BackoffCfg,
755755
type HashMailCourierCfg struct {
756756
// ReceiverAckTimeout is the maximum time we'll wait for the receiver to
757757
// acknowledge the proof.
758-
ReceiverAckTimeout time.Duration `long:"receiveracktimeout" description:"The maximum time to wait for the receiver to acknowledge the proof."`
758+
ReceiverAckTimeout time.Duration `long:"receiveracktimeout" description:"The maximum time to wait for the receiver to acknowledge the proof. Valid time units are {s, m, h}."`
759759

760760
// BackoffCfg configures the behaviour of the proof delivery
761761
// functionality.

sample-tapd.conf

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
; proofcourieraddr=universerpc://testnet.universe.lightning.finance:10029
6060

6161
; The number of seconds the custodian waits after identifying an asset transfer
62-
; on-chain and before retrieving the corresponding proof
62+
; on-chain and before retrieving the corresponding proof. Valid time units are
63+
; {s, m, h}.
6364
; custodianproofretrievaldelay=5s
6465

6566
; Network to run on (mainnet, regtest, testnet, simnet, signet)
@@ -94,7 +95,8 @@
9495
; Use first --tlsextradomain as Common Name instead, if set
9596
; tlsdisableautofill=false
9697

97-
; The duration for which the auto-generated TLS certificate will be valid for
98+
; The duration for which the auto-generated TLS certificate will be valid for.
99+
; Valid time units are {s, m, h}.
98100
; tlscertduration=10080h
99101

100102
; Disable REST API
@@ -103,12 +105,13 @@
103105
; Disable TLS for REST connections
104106
; no-rest-tls=false
105107

106-
; The ping interval for REST based WebSocket connections
107-
; Set to 0 to disable sending ping messages from the server side
108+
; The ping interval for REST based WebSocket connections. Set to 0 to disable
109+
; sending ping messages from the server side. Valid time units are {s, m, h}.
108110
; ws-ping-interval=30s
109111

110112
; The time we wait for a pong response message on REST based WebSocket
111-
; connections before the connection is closed as inactive
113+
; connections before the connection is closed as inactive. Valid time units are
114+
; {s, m, h}.
112115
; ws-pong-wait=5s
113116

114117
; Path to write the admin macaroon for tapd's RPC and REST services if it
@@ -154,25 +157,27 @@
154157

155158
[hashmailcourier]
156159

157-
; The maximum time to wait for the receiver to acknowledge the proof
160+
; The maximum time to wait for the receiver to acknowledge the proof. Valid time
161+
; units are {s, m, h}.
158162
; hashmailcourier.receiveracktimeout=6h
159163

160164
; Skip the initial delay before attempting to deliver the proof to the receiver
161165
; or receiving from the sender
162166
; hashmailcourier.skipinitdelay=false
163167

164-
; The amount of time to wait before resetting the backoff counter
168+
; The amount of time to wait before resetting the backoff counter. Valid time
169+
; units are {s, m, h}.
165170
; hashmailcourier.backoffresetwait=10m
166171

167172
; The number of proof delivery attempts before the backoff counter is reset
168173
; hashmailcourier.numtries=2000
169174

170175
; The initial backoff time to wait before retrying to deliver the proof to the
171-
; receiver
176+
; receiver. Valid time units are {s, m, h}.
172177
; hashmailcourier.initialbackoff=30s
173178

174179
; The maximum backoff time to wait before retrying to deliver the proof to the
175-
; receiver
180+
; receiver. Valid time units are {s, m, h}.
176181
; hashmailcourier.maxbackoff=5m
177182

178183
[universerpccourier]
@@ -181,18 +186,19 @@
181186
; or receiving from the sender
182187
; universerpccourier.skipinitdelay=false
183188

184-
; The amount of time to wait before resetting the backoff counter
189+
; The amount of time to wait before resetting the backoff counter. Valid time
190+
; units are {s, m, h}.
185191
; universerpccourier.backoffresetwait=10m
186192

187193
; The number of proof delivery attempts before the backoff counter is reset
188194
; universerpccourier.numtries=2000
189195

190196
; The initial backoff time to wait before retrying to deliver the proof to the
191-
; receiver
197+
; receiver. Valid time units are {s, m, h}.
192198
; universerpccourier.initialbackoff=30s
193199

194200
; The maximum backoff time to wait before retrying to deliver the proof to the
195-
; receiver
201+
; receiver. Valid time units are {s, m, h}.
196202
; universerpccourier.maxbackoff=5m
197203

198204
[lnd]
@@ -214,7 +220,8 @@
214220
; lnd.tlspath=
215221

216222
; The timeout to use for RPC requests to lnd; a sufficiently long duration
217-
; should be chosen to avoid issues with slow responses
223+
; should be chosen to avoid issues with slow responses. Valid time units are
224+
; {s, m, h}.
218225
; lnd.rpctimeout=1m
219226

220227
[sqlite]
@@ -254,18 +261,20 @@
254261
; Max number of idle connections to keep in the connection pool
255262
; postgres.maxidleconnections=
256263

257-
; Max amount of time a connection can be reused for before it is closed
264+
; Max amount of time a connection can be reused for before it is closed. Valid
265+
; time units are {s, m, h}.
258266
; postgres.connmaxlifetime=
259267

260-
; Max amount of time a connection can be idle for before it is closed
268+
; Max amount of time a connection can be idle for before it is closed. Valid
269+
; time units are {s, m, h}.
261270
; postgres.connmaxidletime=
262271

263272
; Whether to require using SSL (mode: require) when connecting to the server
264273
; postgres.requiressl=false
265274

266275
[universe]
267276

268-
; Amount of time to wait between universe syncs
277+
; Amount of time to wait between universe syncs. Valid time units are {s, m, h}.
269278
; universe.syncinterval=10m
270279

271280
; The host:port of a Universe server peer with
@@ -285,7 +294,8 @@
285294
; If 'w' is included, public access is allowed for write endpoints
286295
; universe.public-access=
287296

288-
; The amount of time to cache stats for before refreshing them
297+
; The amount of time to cache stats for before refreshing them. Valid time units
298+
; are {s, m, h}.
289299
; universe.stats-cache-duration=
290300

291301
; The maximum number of queries per second across the set of active universe

tapcfg/config.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,12 @@ type RpcConfig struct {
224224
TLSExtraDomains []string `long:"tlsextradomain" description:"Adds an extra domain to the generated certificate"`
225225
TLSAutoRefresh bool `long:"tlsautorefresh" description:"Re-generate TLS certificate and key if the IPs or domains are changed"`
226226
TLSDisableAutofill bool `long:"tlsdisableautofill" description:"Do not include the interface IPs or the system hostname in TLS certificate, use first --tlsextradomain as Common Name instead, if set"`
227-
TLSCertDuration time.Duration `long:"tlscertduration" description:"The duration for which the auto-generated TLS certificate will be valid for"`
227+
TLSCertDuration time.Duration `long:"tlscertduration" description:"The duration for which the auto-generated TLS certificate will be valid for. Valid time units are {s, m, h}."`
228228

229229
DisableRest bool `long:"norest" description:"Disable REST API"`
230230
DisableRestTLS bool `long:"no-rest-tls" description:"Disable TLS for REST connections"`
231-
WSPingInterval time.Duration `long:"ws-ping-interval" description:"The ping interval for REST based WebSocket connections, set to 0 to disable sending ping messages from the server side"`
232-
WSPongWait time.Duration `long:"ws-pong-wait" description:"The time we wait for a pong response message on REST based WebSocket connections before the connection is closed as inactive"`
231+
WSPingInterval time.Duration `long:"ws-ping-interval" description:"The ping interval for REST based WebSocket connections, set to 0 to disable sending ping messages from the server side. Valid time units are {s, m, h}."`
232+
WSPongWait time.Duration `long:"ws-pong-wait" description:"The time we wait for a pong response message on REST based WebSocket connections before the connection is closed as inactive. Valid time units are {s, m, h}."`
233233

234234
MacaroonPath string `long:"macaroonpath" description:"Path to write the admin macaroon for tapd's RPC and REST services if it doesn't exist"`
235235
NoMacaroons bool `long:"no-macaroons" description:"Disable macaroon authentication, can only be used if server is not listening on a public interface."`
@@ -264,23 +264,23 @@ type LndConfig struct {
264264
TLSPath string `long:"tlspath" description:"Path to lnd tls certificate"`
265265

266266
// RPCTimeout is the timeout we'll use for RPC requests to lnd.
267-
RPCTimeout time.Duration `long:"rpctimeout" description:"The timeout to use for RPC requests to lnd; a sufficiently long duration should be chosen to avoid issues with slow responses"`
267+
RPCTimeout time.Duration `long:"rpctimeout" description:"The timeout to use for RPC requests to lnd; a sufficiently long duration should be chosen to avoid issues with slow responses. Valid time units are {s, m, h}."`
268268
}
269269

270270
// UniverseConfig is the config that houses any Universe related config
271271
// values.
272272
//
273273
// nolint: lll
274274
type UniverseConfig struct {
275-
SyncInterval time.Duration `long:"syncinterval" description:"Amount of time to wait between universe syncs"`
275+
SyncInterval time.Duration `long:"syncinterval" description:"Amount of time to wait between universe syncs. Valid time units are {s, m, h}."`
276276

277277
FederationServers []string `long:"federationserver" description:"The host:port of a Universe server peer with. These servers will be added as the default set of federation servers. Can be specified multiple times."`
278278

279279
SyncAllAssets bool `long:"sync-all-assets" description:"If set, the federation syncer will default to syncing all assets."`
280280

281281
PublicAccess string `long:"public-access" description:"The public access mode for the universe server, controlling whether remote parties can read from and/or write to this universe server over RPC if exposed to a public network interface. This can be unset, 'r', 'w', or 'rw'. If unset, public access is not enabled for the universe server. If 'r' is included, public access is allowed for read-only endpoints. If 'w' is included, public access is allowed for write endpoints."`
282282

283-
StatsCacheDuration time.Duration `long:"stats-cache-duration" description:"The amount of time to cache stats for before refreshing them."`
283+
StatsCacheDuration time.Duration `long:"stats-cache-duration" description:"The amount of time to cache stats for before refreshing them. Valid time units are {s, m, h}."`
284284

285285
UniverseQueriesPerSecond rate.Limit `long:"max-qps" description:"The maximum number of queries per second across the set of active universe queries that is permitted. Anything above this starts to get rate limited."`
286286

@@ -329,7 +329,7 @@ type Config struct {
329329
HashMailCourier *proof.HashMailCourierCfg `group:"hashmailcourier" namespace:"hashmailcourier"`
330330
UniverseRpcCourier *proof.UniverseRpcCourierCfg `group:"universerpccourier" namespace:"universerpccourier"`
331331

332-
CustodianProofRetrievalDelay time.Duration `long:"custodianproofretrievaldelay" description:"The number of seconds the custodian waits after identifying an asset transfer on-chain and before retrieving the corresponding proof."`
332+
CustodianProofRetrievalDelay time.Duration `long:"custodianproofretrievaldelay" description:"The number of seconds the custodian waits after identifying an asset transfer on-chain and before retrieving the corresponding proof. Valid time units are {s, m, h}."`
333333

334334
ChainConf *ChainConfig
335335
RpcConf *RpcConfig

tapdb/postgres.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ type PostgresConfig struct {
5252
DBName string `long:"dbname" description:"Database name to use."`
5353
MaxOpenConnections int `long:"maxconnections" description:"Max open connections to keep alive to the database server."`
5454
MaxIdleConnections int `long:"maxidleconnections" description:"Max number of idle connections to keep in the connection pool."`
55-
ConnMaxLifetime time.Duration `long:"connmaxlifetime" description:"Max amount of time a connection can be reused for before it is closed."`
56-
ConnMaxIdleTime time.Duration `long:"connmaxidletime" description:"Max amount of time a connection can be idle for before it is closed."`
55+
ConnMaxLifetime time.Duration `long:"connmaxlifetime" description:"Max amount of time a connection can be reused for before it is closed. Valid time units are {s, m, h}."`
56+
ConnMaxIdleTime time.Duration `long:"connmaxidletime" description:"Max amount of time a connection can be idle for before it is closed. Valid time units are {s, m, h}."`
5757
RequireSSL bool `long:"requiressl" description:"Whether to require using SSL (mode: require) when connecting to the server."`
5858
}
5959

0 commit comments

Comments
 (0)