include/entropic/core/compactor_registry.h

← API

include/entropic/core/compactor_registry.h

Types

using entropic::CompactorFn = typedef std::function<CompactionResult( const std::vector<Message>& messages, const CompactionConfig& config, const std::string& identity)>

Internal C++ compactor function type.

Takes messages + config + identity, returns CompactionResult. Wraps C function pointers with C++ types for internal use.

entropic::CompactorEntry

A registered compactor entry.

entropic_compactor_fn entropic::CompactorEntry::c_callback

C function pointer (NULL for C++ compactors)

void* entropic::CompactorEntry::user_data

Opaque data for C callback.

CompactorFn entropic::CompactorEntry::cpp_fn

C++ function (wraps c_callback or native)

entropic::CompactorRegistry

Per-identity compactor registry and dispatch.

entropic::CompactorRegistry::CompactorRegistry(CompactionManager &default_manager)

Construct with default compactor.

Construct with default compactor wrapping CompactionManager.

Parameters
  • default_manager — Reference to v1.8.4 CompactionManager.
  • default_manager — v1.8.4 CompactionManager reference.

entropic_error_t entropic::CompactorRegistry::register_compactor(const std::string &identity, entropic_compactor_fn compactor, void *user_data)

Register a compactor for a specific identity.

Replaces any previously registered compactor for this identity.

Parameters
  • identity — Identity name ("" for global fallback).
  • compactor — C function pointer.
  • user_data — Opaque pointer passed to compactor.
  • user_data — Opaque pointer.
Returns
  • ENTROPIC_OK on success. ENTROPIC_ERROR_INVALID_CONFIG if compactor is NULL.
  • ENTROPIC_OK or ENTROPIC_ERROR_INVALID_CONFIG.
threadsafety
Write-locks the registry.

entropic_error_t entropic::CompactorRegistry::deregister_compactor(const std::string &identity)

Deregister a compactor for a specific identity.

After deregistration, the identity falls back to the global custom compactor (if any), then to the built-in default.

Parameters
  • identity — Identity name ("" for global fallback).
  • identity — Identity name ("" for global).
Returns
  • ENTROPIC_OK on success (idempotent).
  • ENTROPIC_OK (idempotent).
threadsafety
Write-locks the registry.

CompactionResult entropic::CompactorRegistry::compact(const std::string &identity, const std::vector< Message > &messages, const CompactionConfig &config)

Run compaction using the appropriate compactor.

Resolve and call the appropriate compactor. Resolution: per-identity → global custom → built-in default. On custom compactor failure, falls back to default with WARNING.

Parameters
  • identity — Current identity name.
  • messages — Messages to compact.
  • config — Compaction configuration.
Returns
  • CompactionResult with compacted messages and metadata.
  • CompactionResult with metadata.
threadsafety
Read-locks to snapshot, releases before calling.

bool entropic::CompactorRegistry::has_custom_compactor(const std::string &identity) const

Check if a custom compactor is registered for an identity.

Parameters
  • identity — Identity name.
Returns
  • true if a non-default compactor will be used.
  • true if per-identity or global custom registered.
threadsafety
Read-locks the registry.

CompactionManager & entropic::CompactorRegistry::default_manager()

Get the default CompactionManager reference.

Returns
Reference to the v1.8.4 CompactionManager.