@@ -26,10 +26,11 @@ use std::sync::Arc;
2626use url:: Url ;
2727
2828use crate :: oidc:: { self , OpenidConfig } ;
29- use crate :: storage:: { FSConfig , ObjectStorageProvider , S3Config , LOCAL_SYNC_INTERVAL } ;
29+ use crate :: storage:: { FSConfig , ObjectStorageProvider , S3Config } ;
3030use crate :: utils:: validate_path_is_writeable;
3131
3232pub const MIN_CACHE_SIZE_BYTES : u64 = 1000u64 . pow ( 3 ) ; // 1 GiB
33+ pub const MIN_QUERY_MEM_POOL_SIZE_BYTES : u64 = 1000u64 . pow ( 3 ) ; // 1 GiB
3334
3435pub static CONFIG : Lazy < Arc < Config > > = Lazy :: new ( || Arc :: new ( Config :: new ( ) ) ) ;
3536
@@ -98,13 +99,6 @@ impl Config {
9899 _ => unreachable ! ( ) ,
99100 }
100101 }
101-
102- pub fn validate ( & self ) {
103- if CONFIG . parseable . upload_interval < LOCAL_SYNC_INTERVAL {
104- panic ! ( "object storage upload_interval (P_STORAGE_UPLOAD_INTERVAL) must be 60 seconds or more" ) ;
105- }
106- }
107-
108102 pub fn validate_staging ( & self ) -> anyhow:: Result < ( ) > {
109103 let staging_path = self . staging_dir ( ) ;
110104 validate_path_is_writeable ( staging_path)
@@ -412,17 +406,17 @@ impl Server {
412406 . env ( "P_CACHE_DIR" )
413407 . value_name ( "DIR" )
414408 . value_parser ( validation:: canonicalize_path)
415- . help ( "Local path to be used for caching latest files " )
409+ . help ( "Local path on this device to be used for caching data " )
416410 . next_line_help ( true ) ,
417411 )
418412 . arg (
419413 Arg :: new ( Self :: CACHE_SIZE )
420414 . long ( Self :: CACHE_SIZE )
421415 . env ( "P_CACHE_SIZE" )
422416 . value_name ( "size" )
423- . default_value ( "1Gib " )
424- . value_parser ( validation:: human_size_to_bytes )
425- . help ( "Size for cache in human readable format ( e.g 1GiB, 2GiB, 100MB)" )
417+ . default_value ( "1GiB " )
418+ . value_parser ( validation:: cache_size )
419+ . help ( "Maximum allowed cache size for all streams combined (In human readable format, e.g 1GiB, 2GiB, 100MB)" )
426420 . next_line_help ( true ) ,
427421 )
428422 . arg (
@@ -431,7 +425,7 @@ impl Server {
431425 . env ( "P_STORAGE_UPLOAD_INTERVAL" )
432426 . value_name ( "SECONDS" )
433427 . default_value ( "60" )
434- . value_parser ( value_parser ! ( u64 ) )
428+ . value_parser ( validation :: upload_interval )
435429 . help ( "Interval in seconds after which staging data would be sent to the storage" )
436430 . next_line_help ( true ) ,
437431 )
@@ -441,15 +435,15 @@ impl Server {
441435 . env ( "P_USERNAME" )
442436 . value_name ( "STRING" )
443437 . required ( true )
444- . help ( "Admin username for this server" ) ,
438+ . help ( "Admin username to be set for this Parseable server" ) ,
445439 )
446440 . arg (
447441 Arg :: new ( Self :: PASSWORD )
448442 . long ( Self :: PASSWORD )
449443 . env ( "P_PASSWORD" )
450444 . value_name ( "STRING" )
451445 . required ( true )
452- . help ( "Admin password for this server" ) ,
446+ . help ( "Admin password to be set for this Parseable server" ) ,
453447 )
454448 . arg (
455449 Arg :: new ( Self :: CHECK_UPDATE )
@@ -459,7 +453,7 @@ impl Server {
459453 . required ( false )
460454 . default_value ( "true" )
461455 . value_parser ( value_parser ! ( bool ) )
462- . help ( "Disable/ Enable checking for updates " ) ,
456+ . help ( "Enable/Disable checking for new Parseable release " ) ,
463457 )
464458 . arg (
465459 Arg :: new ( Self :: SEND_ANALYTICS )
@@ -469,15 +463,15 @@ impl Server {
469463 . required ( false )
470464 . default_value ( "true" )
471465 . value_parser ( value_parser ! ( bool ) )
472- . help ( "Disable/ Enable sending anonymous telemetry" ) ,
466+ . help ( "Enable/Disable anonymous telemetry data collection " ) ,
473467 )
474468 . arg (
475469 Arg :: new ( Self :: OPEN_AI_KEY )
476470 . long ( Self :: OPEN_AI_KEY )
477471 . env ( "P_OPENAI_API_KEY" )
478472 . value_name ( "STRING" )
479473 . required ( false )
480- . help ( "OpenAI key to enable llm feature " ) ,
474+ . help ( "OpenAI key to enable llm features " ) ,
481475 )
482476 . arg (
483477 Arg :: new ( Self :: OPENID_CLIENT_ID )
@@ -539,8 +533,8 @@ impl Server {
539533 . env ( "P_QUERY_MEMORY_LIMIT" )
540534 . value_name ( "STRING" )
541535 . required ( false )
542- . value_parser ( validation:: size )
543- . help ( "Memory allocated to query in human readable format ( e.g 1GiB, 2GiB, 100MB)" ) ,
536+ . value_parser ( validation:: query_memory_pool_size )
537+ . help ( "Memory allocated to query sub system (In human readable format, e.g 1GiB, 2GiB, 100MB)" ) ,
544538 )
545539 . arg (
546540 Arg :: new ( Self :: ROW_GROUP_SIZE )
@@ -612,10 +606,11 @@ pub mod validation {
612606 str:: FromStr ,
613607 } ;
614608
615- use human_size:: SpecificSize ;
616-
617- use crate :: option:: MIN_CACHE_SIZE_BYTES ;
609+ use human_size:: { SpecificSize , multiples} ;
618610
611+ use crate :: option:: { MIN_CACHE_SIZE_BYTES , MIN_QUERY_MEM_POOL_SIZE_BYTES } ;
612+ use crate :: storage:: LOCAL_SYNC_INTERVAL ;
613+
619614 pub fn file_path ( s : & str ) -> Result < PathBuf , String > {
620615 if s. is_empty ( ) {
621616 return Err ( "empty path" . to_owned ( ) ) ;
@@ -652,8 +647,7 @@ pub mod validation {
652647 url:: Url :: parse ( s) . map_err ( |_| "Invalid URL provided" . to_string ( ) )
653648 }
654649
655- pub fn human_size_to_bytes ( s : & str ) -> Result < u64 , String > {
656- use human_size:: multiples;
650+ fn human_size_to_bytes ( s : & str ) -> Result < u64 , String > {
657651 fn parse_and_map < T : human_size:: Multiple > (
658652 s : & str ,
659653 ) -> Result < u64 , human_size:: ParsingError > {
@@ -668,12 +662,35 @@ pub mod validation {
668662 . or ( parse_and_map :: < multiples:: Terabyte > ( s) )
669663 . map_err ( |_| "Could not parse given size" . to_string ( ) ) ?;
670664
665+ Ok ( size)
666+ }
667+
668+ pub fn cache_size ( s : & str ) -> Result < u64 , String > {
669+ let size = human_size_to_bytes ( s) ?;
671670 if size < MIN_CACHE_SIZE_BYTES {
672671 return Err (
673672 "Specified value of cache size is smaller than current minimum of 1GiB" . to_string ( ) ,
674673 ) ;
675674 }
675+ Ok ( size)
676+ }
676677
678+ pub fn query_memory_pool_size ( s : & str ) -> Result < u64 , String > {
679+ let size = human_size_to_bytes ( s) ?;
680+ if size < MIN_QUERY_MEM_POOL_SIZE_BYTES {
681+ return Err (
682+ "Specified value of query memory pool size is smaller than current minimum of 1GiB" . to_string ( ) ,
683+ ) ;
684+ }
677685 Ok ( size)
678686 }
687+
688+ pub fn upload_interval ( s : & str ) -> Result < u64 , String > {
689+ let u = s. parse :: < u64 > ( ) . map_err ( |_| "invalid upload interval" . to_string ( ) ) ?;
690+ if u < LOCAL_SYNC_INTERVAL {
691+ return Err ( "object storage upload interval must be 60 seconds or more" . to_string ( ) ) ;
692+ }
693+ Ok ( u)
694+ }
695+
679696}
0 commit comments