Entropic 2.11.1
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
31extern "C" ENTROPIC_EXPORT entropic_error_t
33 entropic_handle_t handle,
34 const char* db_path) {
35
36 if (!handle || !db_path) {
37 return !handle ? ENTROPIC_ERROR_INVALID_HANDLE
39 }
40
41 try {
42 handle->storage = std::make_unique<entropic::SqliteStorageBackend>(db_path);
43 if (!handle->storage->initialize()) {
44 handle->storage.reset();
45 throw std::runtime_error("SQLite init failed");
46 }
47 logger->info("storage_open: path='{}'", db_path);
48 return ENTROPIC_OK;
49 } catch (const std::exception& e) {
50 handle->last_error = e.what();
51 logger->error("storage_open: {}", handle->last_error);
53 }
54}
55
65extern "C" ENTROPIC_EXPORT entropic_error_t
67 if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
68 handle->storage.reset();
69 logger->info("storage_close");
70 return ENTROPIC_OK;
71}
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:37
@ ENTROPIC_OK
Success.
Definition error.h:38
@ ENTROPIC_ERROR_INVALID_ARGUMENT
NULL pointer, empty string, out-of-range value.
Definition error.h:39
@ ENTROPIC_ERROR_INVALID_HANDLE
NULL or destroyed handle (v1.8.9)
Definition error.h:57
@ ENTROPIC_ERROR_STORAGE_FAILED
Storage operation failed (v1.8.9)
Definition error.h:59
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.