adding message frag object version and conversion work, but comp name changes incoming
This commit is contained in:
parent
a9f6a5d763
commit
85a29372f4
@ -64,12 +64,13 @@ target_link_libraries(message_fragment_store PUBLIC
|
|||||||
|
|
||||||
########################################
|
########################################
|
||||||
|
|
||||||
add_executable(convert_frag_to_obj
|
add_executable(convert_message_object_store
|
||||||
fragment_store/convert_frag_to_obj.cpp
|
fragment_store/convert_frag_to_obj.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(convert_frag_to_obj PUBLIC
|
target_link_libraries(convert_message_object_store PUBLIC
|
||||||
fragment_store
|
fragment_store
|
||||||
|
message_fragment_store
|
||||||
)
|
)
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "./backends/filesystem_storage.hpp"
|
#include "./backends/filesystem_storage.hpp"
|
||||||
#include "./meta_components.hpp"
|
#include "./meta_components.hpp"
|
||||||
#include "./serializer_json.hpp"
|
#include "./serializer_json.hpp"
|
||||||
|
#include "./message_fragment_store.hpp"
|
||||||
|
|
||||||
#include <solanaceae/util/utils.hpp>
|
#include <solanaceae/util/utils.hpp>
|
||||||
|
|
||||||
@ -31,6 +32,13 @@ int main(int argc, const char** argv) {
|
|||||||
backend::FilesystemStorage fsb_src(os_src, argv[1]);
|
backend::FilesystemStorage fsb_src(os_src, argv[1]);
|
||||||
backend::FilesystemStorage fsb_dst(os_dst, argv[2]);
|
backend::FilesystemStorage fsb_dst(os_dst, argv[2]);
|
||||||
|
|
||||||
|
Contact3Registry cr; // dummy
|
||||||
|
RegistryMessageModel rmm(cr); // dummy
|
||||||
|
// they only exist for the serializers (for now)
|
||||||
|
// TODO: version
|
||||||
|
MessageFragmentStore mfs_src(cr, rmm, os_src, fsb_src);
|
||||||
|
MessageFragmentStore mfs_dst(cr, rmm, os_dst, fsb_dst);
|
||||||
|
|
||||||
// add message fragment store too (adds meta?)
|
// add message fragment store too (adds meta?)
|
||||||
|
|
||||||
// hookup events
|
// hookup events
|
||||||
|
@ -71,6 +71,7 @@ namespace Message::Components {
|
|||||||
} // Message::Components
|
} // Message::Components
|
||||||
|
|
||||||
namespace ObjectStore::Components {
|
namespace ObjectStore::Components {
|
||||||
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MessagesVersion, v)
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MessagesTSRange, begin, end)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MessagesTSRange, begin, end)
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MessagesContact, id)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MessagesContact, id)
|
||||||
|
|
||||||
@ -228,6 +229,7 @@ void MessageFragmentStore::handleMessage(const Message3Handle& m) {
|
|||||||
|
|
||||||
fh.emplace_or_replace<ObjComp::Ephemeral::MetaCompressionType>().comp = Compression::ZSTD;
|
fh.emplace_or_replace<ObjComp::Ephemeral::MetaCompressionType>().comp = Compression::ZSTD;
|
||||||
fh.emplace_or_replace<ObjComp::DataCompressionType>().comp = Compression::ZSTD;
|
fh.emplace_or_replace<ObjComp::DataCompressionType>().comp = Compression::ZSTD;
|
||||||
|
fh.emplace_or_replace<ObjComp::MessagesVersion>(); // default is current
|
||||||
|
|
||||||
auto& new_ts_range = fh.emplace_or_replace<ObjComp::MessagesTSRange>();
|
auto& new_ts_range = fh.emplace_or_replace<ObjComp::MessagesTSRange>();
|
||||||
new_ts_range.begin = msg_ts;
|
new_ts_range.begin = msg_ts;
|
||||||
@ -464,7 +466,11 @@ bool MessageFragmentStore::syncFragToStorage(ObjectHandle fh, Message3Registry&
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
s_cb_it->second(_sc, {reg, m}, j_entry[storage.type().name()]);
|
s_cb_it->second(_sc, {reg, m}, j_entry[storage.type().name()]);
|
||||||
|
} catch (...) {
|
||||||
|
std::cerr << "MFS error: failed to serialize " << storage.type().name() << "(" << type_id << ")\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,12 +508,14 @@ MessageFragmentStore::MessageFragmentStore(
|
|||||||
_rmm.subscribe(this, RegistryMessageModel_Event::message_destroy);
|
_rmm.subscribe(this, RegistryMessageModel_Event::message_destroy);
|
||||||
|
|
||||||
auto& sjc = _os.registry().ctx().get<SerializerJsonCallbacks<Object>>();
|
auto& sjc = _os.registry().ctx().get<SerializerJsonCallbacks<Object>>();
|
||||||
|
sjc.registerSerializer<ObjComp::MessagesVersion>();
|
||||||
|
sjc.registerDeSerializer<ObjComp::MessagesVersion>();
|
||||||
sjc.registerSerializer<ObjComp::MessagesTSRange>();
|
sjc.registerSerializer<ObjComp::MessagesTSRange>();
|
||||||
sjc.registerDeSerializer<ObjComp::MessagesTSRange>();
|
sjc.registerDeSerializer<ObjComp::MessagesTSRange>();
|
||||||
sjc.registerSerializer<ObjComp::MessagesContact>();
|
sjc.registerSerializer<ObjComp::MessagesContact>();
|
||||||
sjc.registerDeSerializer<ObjComp::MessagesContact>();
|
sjc.registerDeSerializer<ObjComp::MessagesContact>();
|
||||||
|
|
||||||
// old
|
// old frag names
|
||||||
sjc.registerSerializer<FragComp::MessagesTSRange>(sjc.component_get_json<ObjComp::MessagesTSRange>);
|
sjc.registerSerializer<FragComp::MessagesTSRange>(sjc.component_get_json<ObjComp::MessagesTSRange>);
|
||||||
sjc.registerDeSerializer<FragComp::MessagesTSRange>(sjc.component_emplace_or_replace_json<ObjComp::MessagesTSRange>);
|
sjc.registerDeSerializer<FragComp::MessagesTSRange>(sjc.component_emplace_or_replace_json<ObjComp::MessagesTSRange>);
|
||||||
sjc.registerSerializer<FragComp::MessagesContact>(sjc.component_get_json<ObjComp::MessagesContact>);
|
sjc.registerSerializer<FragComp::MessagesContact>(sjc.component_get_json<ObjComp::MessagesContact>);
|
||||||
@ -625,6 +633,15 @@ float MessageFragmentStore::tick(float) {
|
|||||||
return 0.05f;
|
return 0.05f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fh.all_of<ObjComp::MessagesVersion>()) {
|
||||||
|
// missing version, adding
|
||||||
|
fh.emplace<ObjComp::MessagesVersion>();
|
||||||
|
}
|
||||||
|
if (fh.get<ObjComp::MessagesVersion>().v != 1) {
|
||||||
|
std::cerr << "MFS: object with version mismatch\n";
|
||||||
|
return 0.05f;
|
||||||
|
}
|
||||||
|
|
||||||
// get ts range of frag and collide with all curser(s/ranges)
|
// get ts range of frag and collide with all curser(s/ranges)
|
||||||
const auto& frag_range = fh.get<ObjComp::MessagesTSRange>();
|
const auto& frag_range = fh.get<ObjComp::MessagesTSRange>();
|
||||||
|
|
||||||
@ -837,6 +854,11 @@ bool MessageFragmentStore::onEvent(const ObjectStore::Events::ObjectConstruct& e
|
|||||||
if (!e.e.all_of<ObjComp::MessagesTSRange, ObjComp::MessagesContact>()) {
|
if (!e.e.all_of<ObjComp::MessagesTSRange, ObjComp::MessagesContact>()) {
|
||||||
return false; // not for us
|
return false; // not for us
|
||||||
}
|
}
|
||||||
|
if (!e.e.all_of<ObjComp::MessagesVersion>()) {
|
||||||
|
// missing version, adding
|
||||||
|
// version check is later
|
||||||
|
e.e.emplace<ObjComp::MessagesVersion>();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: are we sure it is a *new* fragment?
|
// TODO: are we sure it is a *new* fragment?
|
||||||
|
|
||||||
|
@ -55,6 +55,12 @@ namespace Message::Components {
|
|||||||
} // Message::Components
|
} // Message::Components
|
||||||
|
|
||||||
namespace ObjectStore::Components {
|
namespace ObjectStore::Components {
|
||||||
|
struct MessagesVersion {
|
||||||
|
// messages Object version
|
||||||
|
// 1 -> text_json
|
||||||
|
uint16_t v {1};
|
||||||
|
};
|
||||||
|
|
||||||
struct MessagesTSRange {
|
struct MessagesTSRange {
|
||||||
// timestamp range within the fragment
|
// timestamp range within the fragment
|
||||||
uint64_t begin {0}; // newer msg -> higher number
|
uint64_t begin {0}; // newer msg -> higher number
|
||||||
|
Loading…
Reference in New Issue
Block a user