@@ -11,6 +11,7 @@ use std::str::{self, SplitWhitespace};
11
11
use std:: vec:: Vec ;
12
12
13
13
use super :: format:: unescape;
14
+ use super :: statistics:: ChannelStatistics ;
14
15
use crate :: query:: builder:: { QueryBuilder , QueryBuilderResult } ;
15
16
use crate :: query:: types:: { QueryGenericLang , QuerySearchLimit , QuerySearchOffset } ;
16
17
use crate :: store:: fst:: StoreFSTPool ;
@@ -62,7 +63,7 @@ lazy_static! {
62
63
pub static ref COMMANDS_MODE_INGEST : Vec <& ' static str > =
63
64
vec![ "PUSH" , "POP" , "COUNT" , "FLUSHC" , "FLUSHB" , "FLUSHO" , "PING" , "HELP" , "QUIT" ] ;
64
65
pub static ref COMMANDS_MODE_CONTROL : Vec <& ' static str > =
65
- vec![ "TRIGGER" , "PING" , "HELP" , "QUIT" ] ;
66
+ vec![ "TRIGGER" , "INFO" , " PING", "HELP" , "QUIT" ] ;
66
67
pub static ref CONTROL_TRIGGER_ACTIONS : Vec <& ' static str > = vec![ "consolidate" ] ;
67
68
static ref MANUAL_MODE_SEARCH : HashMap <& ' static str , & ' static Vec <& ' static str >> =
68
69
[ ( "commands" , & * COMMANDS_MODE_SEARCH ) ]
@@ -794,12 +795,34 @@ impl ChannelCommandControl {
794
795
_ => Err ( ChannelCommandError :: NotFound ) ,
795
796
}
796
797
} else {
797
- Err ( ChannelCommandError :: InvalidFormat ( "HELP [<action>]?" ) )
798
+ Err ( ChannelCommandError :: InvalidFormat ( "TRIGGER [<action>]?" ) )
798
799
}
799
800
}
800
801
}
801
802
}
802
803
804
+ pub fn dispatch_info ( _parts : SplitWhitespace ) -> ChannelResult {
805
+ if let Ok ( statistics) = ChannelStatistics :: gather ( ) {
806
+ let statistics_result = format ! (
807
+ "uptime({}) clients_connected({}) commands_total({}) \
808
+ command_latency_best({}) command_latency_worst({}) \
809
+ kv_open_count({}) fst_open_count({}) fst_consolidate_count({})",
810
+ statistics. uptime,
811
+ statistics. clients_connected,
812
+ statistics. commands_total,
813
+ statistics. command_latency_best,
814
+ statistics. command_latency_worst,
815
+ statistics. kv_open_count,
816
+ statistics. fst_open_count,
817
+ statistics. fst_consolidate_count
818
+ ) ;
819
+
820
+ Ok ( vec ! [ ChannelCommandResponse :: Result ( statistics_result) ] )
821
+ } else {
822
+ Err ( ChannelCommandError :: InternalError )
823
+ }
824
+ }
825
+
803
826
pub fn dispatch_help ( parts : SplitWhitespace ) -> ChannelResult {
804
827
ChannelCommandBase :: generic_dispatch_help ( parts, & * MANUAL_MODE_CONTROL )
805
828
}
0 commit comments