Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic_storage.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
12#include "engine_handle.h"
13
14#include <entropic/entropic.h>
16#include <stdexcept>
17
18static auto logger = entropic::log::get("facade.storage");
19
29extern "C" ENTROPIC_EXPORT entropic_error_t
31 entropic_handle_t handle,
32 const char* db_path) {
33
34 if (!handle || !db_path) {
35 return !handle ? ENTROPIC_ERROR_INVALID_HANDLE
37 }
38
39 try {
40 handle->storage = std::make_unique<entropic::SqliteStorageBackend>(db_path);
41 if (!handle->storage->initialize()) {
42 handle->storage.reset();
43 throw std::runtime_error("SQLite init failed");
44 }
45 logger->info("storage_open: path='{}'", db_path);
46 return ENTROPIC_OK;
47 } catch (const std::exception& e) {
48 handle->last_error = e.what();
49 logger->error("storage_open: {}", handle->last_error);
51 }
52}
53
62extern "C" ENTROPIC_EXPORT entropic_error_t
64 if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
65 handle->storage.reset();
66 logger->info("storage_close");
67 return ENTROPIC_OK;
68}
Private definition of the entropic_engine struct.
Public C API for the Entropic inference engine.
ENTROPIC_EXPORT entropic_error_t entropic_storage_open(entropic_handle_t handle, const char *db_path)
Open or create a SQLite storage backend.
ENTROPIC_EXPORT entropic_error_t entropic_storage_close(entropic_handle_t handle)
Close the storage backend.
entropic_error_t
Error codes returned by all C API functions.
Definition error.h:35
@ ENTROPIC_OK
Success.
Definition error.h:36
@ ENTROPIC_ERROR_INVALID_ARGUMENT
NULL pointer, empty string, out-of-range value.
Definition error.h:37
@ ENTROPIC_ERROR_INVALID_HANDLE
NULL or destroyed handle (v1.8.9)
Definition error.h:55
@ ENTROPIC_ERROR_STORAGE_FAILED
Storage operation failed (v1.8.9)
Definition error.h:57
spdlog initialization and logger access.
ENTROPIC_EXPORT std::shared_ptr< spdlog::logger > get(const std::string &name)
Get or create a named logger.
Definition logging.cpp:211
Engine handle struct — owns all subsystems.
std::unique_ptr< entropic::SqliteStorageBackend > storage
SQLite persistence.
std::string last_error
Per-handle error message.