File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -182,13 +182,13 @@ impl AlertTrait for ThresholdAlert {
182182 & mut self ,
183183 new_notification_state : NotificationState ,
184184 ) -> Result < ( ) , AlertError > {
185- // update state in memory
186- self . notification_state = new_notification_state;
187185 // update on disk
188186 PARSEABLE
189187 . metastore
190188 . put_alert ( & self . to_alert_config ( ) )
191189 . await ?;
190+ // update state in memory
191+ self . notification_state = new_notification_state;
192192
193193 Ok ( ( ) )
194194 }
Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ pub trait Metastore: std::fmt::Debug + Send + Sync {
4343 async fn put_alert ( & self , obj : & dyn MetastoreObject ) -> Result < ( ) , MetastoreError > ;
4444 async fn delete_alert ( & self , obj : & dyn MetastoreObject ) -> Result < ( ) , MetastoreError > ;
4545
46+ /// llmconfig
47+ async fn get_llmconfigs ( & self ) -> Result < Vec < Bytes > , MetastoreError > ;
48+ async fn put_llmconfig ( & self , obj : & dyn MetastoreObject ) -> Result < ( ) , MetastoreError > ;
49+ async fn delete_llmconfig ( & self , obj : & dyn MetastoreObject ) -> Result < ( ) , MetastoreError > ;
50+
4651 /// targets
4752 async fn get_targets ( & self ) -> Result < Vec < Target > , MetastoreError > ;
4853 async fn put_target ( & self , obj : & dyn MetastoreObject ) -> Result < ( ) , MetastoreError > ;
Original file line number Diff line number Diff line change @@ -114,6 +114,39 @@ impl Metastore for ObjectStoreMetastore {
114114 . await ?)
115115 }
116116
117+ /// This function fetches all the llmconfigs from the underlying object store
118+ async fn get_llmconfigs ( & self ) -> Result < Vec < Bytes > , MetastoreError > {
119+ let base_path = RelativePathBuf :: from_iter ( [ SETTINGS_ROOT_DIRECTORY , "llmconfigs" ] ) ;
120+ let conf_bytes = self
121+ . storage
122+ . get_objects (
123+ Some ( & base_path) ,
124+ Box :: new ( |file_name| file_name. ends_with ( ".json" ) ) ,
125+ )
126+ . await ?;
127+
128+ Ok ( conf_bytes)
129+ }
130+
131+ /// This function puts an llmconfig in the object store at the given path
132+ async fn put_llmconfig ( & self , obj : & dyn MetastoreObject ) -> Result < ( ) , MetastoreError > {
133+ let path = obj. get_object_path ( ) ;
134+
135+ Ok ( self
136+ . storage
137+ . put_object ( & RelativePathBuf :: from ( path) , to_bytes ( obj) )
138+ . await ?)
139+ }
140+
141+ /// Delete an llmconfig
142+ async fn delete_llmconfig ( & self , obj : & dyn MetastoreObject ) -> Result < ( ) , MetastoreError > {
143+ let path = obj. get_object_path ( ) ;
144+ Ok ( self
145+ . storage
146+ . delete_object ( & RelativePathBuf :: from ( path) )
147+ . await ?)
148+ }
149+
117150 /// Fetch all dashboards
118151 async fn get_dashboards ( & self ) -> Result < Vec < Bytes > , MetastoreError > {
119152 let mut dashboards = Vec :: new ( ) ;
You can’t perform that action at this time.
0 commit comments