import json
def create_collection_config(collection_name, max_items, max_size_bytes):
"""
Creates a configuration dictionary for a short-lived collection with hard-coded limits.
Args:
collection_name (str): The name of the collection.
max_items (int): The maximum number of items allowed in the collection.
max_size_bytes (int): The maximum size of the collection in bytes.
Returns:
dict: A dictionary containing the collection configuration.
"""
config = {
"collection_name": collection_name,
"max_items": max_items,
"max_size_bytes": max_size_bytes
}
return config
def write_config_to_json(config, filepath):
"""
Writes the collection configuration to a JSON file.
Args:
config (dict): The collection configuration dictionary.
filepath (str): The path to the JSON file.
"""
with open(filepath, 'w') as f:
json.dump(config, f, indent=4)
if __name__ == '__main__':
# Example usage
collection_name = "temp_data"
max_items = 100
max_size_bytes = 102400 # 100KB
config = create_collection_config(collection_name, max_items, max_size_bytes)
config_filepath = "temp_collection_config.json"
write_config_to_json(config, config_filepath)
Add your comment