@@ -11,7 +11,7 @@ import {
11
11
import { Seconds } from '@cardano-sdk/core' ;
12
12
import { BuildInfo as ServiceBuildInfo } from '../../Http' ;
13
13
import { addOptions , newOption } from './util' ;
14
- import { buildInfoValidator , cacheTtlValidator } from '../../util/validators' ;
14
+ import { buildInfoValidator , floatValidator , integerValidator , urlValidator } from '../../util/validators' ;
15
15
import { loggerMethodNames } from '@cardano-sdk/util' ;
16
16
17
17
export const ENABLE_METRICS_DEFAULT = false ;
@@ -21,17 +21,18 @@ export const LAST_ROS_EPOCHS_DEFAULT = 10;
21
21
enum Descriptions {
22
22
ApiUrl = 'API URL' ,
23
23
BuildInfo = 'Service build info' ,
24
+ DumpOnly = 'Dumps the input arguments and exits. Used for tests' ,
25
+ EnableMetrics = 'Enable Prometheus Metrics' ,
24
26
LastRosEpochs = 'Number of epochs over which lastRos is computed' ,
25
27
LoggerMinSeverity = 'Log level' ,
26
- HealthCheckCacheTtl = 'Health check cache TTL in seconds between 1 and 10' ,
27
- EnableMetrics = 'Enable Prometheus Metrics' ,
28
28
ServiceDiscoveryBackoffFactor = 'Exponential backoff factor for service discovery' ,
29
29
ServiceDiscoveryTimeout = 'Timeout for service discovery attempts'
30
30
}
31
31
32
32
export type CommonProgramOptions = {
33
33
apiUrl : URL ;
34
34
buildInfo ?: ServiceBuildInfo ;
35
+ dumpOnly ?: boolean ;
35
36
enableMetrics ?: boolean ;
36
37
lastRosEpochs ?: number ;
37
38
loggerMinSeverity ?: LogLevel ;
@@ -41,27 +42,23 @@ export type CommonProgramOptions = {
41
42
42
43
export const withCommonOptions = ( command : Command , apiUrl : URL ) => {
43
44
addOptions ( command , [
44
- newOption ( '--api-url <apiUrl>' , Descriptions . ApiUrl , 'API_URL' , ( url ) => new URL ( url ) , apiUrl ) ,
45
+ newOption ( '--api-url <apiUrl>' , Descriptions . ApiUrl , 'API_URL' , urlValidator ( Descriptions . ApiUrl ) , apiUrl ) ,
45
46
newOption ( '--build-info <buildInfo>' , Descriptions . BuildInfo , 'BUILD_INFO' , buildInfoValidator ) ,
47
+ newOption ( '--dump-only <true/false>' , Descriptions . DumpOnly , 'DUMP_ONLY' , ( dumpOnly ) =>
48
+ stringOptionToBoolean ( dumpOnly , Programs . ProviderServer , Descriptions . DumpOnly )
49
+ ) ,
46
50
newOption (
47
51
'--enable-metrics <true/false>' ,
48
52
Descriptions . EnableMetrics ,
49
53
'ENABLE_METRICS' ,
50
54
( enableMetrics ) => stringOptionToBoolean ( enableMetrics , Programs . ProviderServer , Descriptions . EnableMetrics ) ,
51
55
ENABLE_METRICS_DEFAULT
52
56
) ,
53
- newOption (
54
- '--health-check-cache-ttl <healthCheckCacheTTL>' ,
55
- Descriptions . HealthCheckCacheTtl ,
56
- 'HEALTH_CHECK_CACHE_TTL' ,
57
- ( ttl : string ) => cacheTtlValidator ( ttl , { lowerBound : 1 , upperBound : 120 } , Descriptions . HealthCheckCacheTtl ) ,
58
- DEFAULT_HEALTH_CHECK_CACHE_TTL
59
- ) ,
60
57
newOption (
61
58
'--last-ros-epochs <lastRosEpochs>' ,
62
59
Descriptions . LastRosEpochs ,
63
60
'LAST_ROS_EPOCHS' ,
64
- ( lastRosEpochs ) => Number . parseInt ( lastRosEpochs , 10 ) ,
61
+ integerValidator ( Descriptions . LastRosEpochs ) ,
65
62
LAST_ROS_EPOCHS_DEFAULT
66
63
) ,
67
64
newOption (
@@ -78,14 +75,14 @@ export const withCommonOptions = (command: Command, apiUrl: URL) => {
78
75
'--service-discovery-backoff-factor <serviceDiscoveryBackoffFactor>' ,
79
76
Descriptions . ServiceDiscoveryBackoffFactor ,
80
77
'SERVICE_DISCOVERY_BACKOFF_FACTOR' ,
81
- ( factor ) => Number . parseFloat ( factor ) ,
78
+ floatValidator ( Descriptions . ServiceDiscoveryBackoffFactor ) ,
82
79
SERVICE_DISCOVERY_BACKOFF_FACTOR_DEFAULT
83
80
) ,
84
81
newOption (
85
82
'--service-discovery-timeout <serviceDiscoveryTimeout>' ,
86
83
Descriptions . ServiceDiscoveryTimeout ,
87
84
'SERVICE_DISCOVERY_TIMEOUT' ,
88
- ( interval ) => Number . parseInt ( interval , 10 ) ,
85
+ integerValidator ( Descriptions . ServiceDiscoveryTimeout ) ,
89
86
SERVICE_DISCOVERY_TIMEOUT_DEFAULT
90
87
)
91
88
] ) ;
0 commit comments