@@ -45,6 +45,8 @@ pub struct ResolvedRuntimeConfig<T> {
45
45
///
46
46
/// `None` is used for an "unset" log directory.
47
47
pub log_dir : Option < PathBuf > ,
48
+ /// The maximum memory allocation limit.
49
+ pub max_instance_memory : Option < usize > ,
48
50
/// The input TOML, for informational summaries.
49
51
pub toml : toml:: Table ,
50
52
}
@@ -137,12 +139,15 @@ where
137
139
138
140
let toml = toml_resolver. toml ( ) ;
139
141
let log_dir = toml_resolver. log_dir ( ) ?;
142
+ let max_instance_memory = toml_resolver. max_instance_memory ( ) ?;
143
+
140
144
let source = TomlRuntimeConfigSource :: new (
141
145
toml_resolver,
142
146
& key_value_resolver,
143
147
tls_resolver. as_ref ( ) ,
144
148
& sqlite_resolver,
145
149
) ;
150
+
146
151
// Note: all valid fields in the runtime config must have been referenced at
147
152
// this point or the finalizer will fail due to `validate_all_keys_used`
148
153
// not passing.
@@ -154,6 +159,7 @@ where
154
159
sqlite_resolver,
155
160
state_dir,
156
161
log_dir,
162
+ max_instance_memory,
157
163
toml,
158
164
} )
159
165
}
@@ -167,6 +173,11 @@ where
167
173
pub fn log_dir ( & self ) -> Option < PathBuf > {
168
174
self . log_dir . clone ( )
169
175
}
176
+
177
+ /// The maximum memory allocation limit.
178
+ pub fn max_instance_memory ( & self ) -> Option < usize > {
179
+ self . max_instance_memory
180
+ }
170
181
}
171
182
172
183
#[ derive( Clone , Debug ) ]
@@ -261,6 +272,16 @@ impl<'a> TomlResolver<'a> {
261
272
}
262
273
}
263
274
275
+ /// Get the configured maximum memory allocation limit.
276
+ pub fn max_instance_memory ( & self ) -> anyhow:: Result < Option < usize > > {
277
+ self . table
278
+ . get ( "max_instance_memory" )
279
+ . and_then ( |v| v. as_integer ( ) )
280
+ . map ( |toml_value| toml_value. try_into ( ) )
281
+ . transpose ( )
282
+ . map_err ( Into :: into)
283
+ }
284
+
264
285
/// Validate that all keys in the TOML file have been used.
265
286
pub fn validate_all_keys_used ( & self ) -> spin_factors:: Result < ( ) > {
266
287
self . table . validate_all_keys_used ( )
0 commit comments