diff --git a/docs/doxygen/consumer/DoxygenLayout.xml b/docs/doxygen/consumer/DoxygenLayout.xml index df771ade6f9924c4cbdd2c5b4d67835e752e117c..a068d9560425e54851485ca29819a7bfc381222b 100644 --- a/docs/doxygen/consumer/DoxygenLayout.xml +++ b/docs/doxygen/consumer/DoxygenLayout.xml @@ -1,5 +1,5 @@ <doxygenlayout version="1.0"> - <!-- Generated by doxygen 1.8.17 --> + <!-- Generated by doxygen 1.8.11 --> <!-- Navigation index tabs for HTML output --> <navindex> <tab type="user" url="../index.html" visible="yes" title="Main ASAP::O"/> @@ -10,26 +10,12 @@ <tab type="namespacelist" visible="yes" title="" intro=""/> <tab type="namespacemembers" visible="yes" title="" intro=""/> </tab> - <tab type="interfaces" visible="yes" title=""> - <tab type="interfacelist" visible="yes" title="" intro=""/> - <tab type="interfaceindex" visible="$ALPHABETICAL_INDEX" title=""/> - <tab type="interfacehierarchy" visible="yes" title="" intro=""/> - </tab> <tab type="classes" visible="yes" title=""> <tab type="classlist" visible="yes" title="" intro=""/> <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/> <tab type="hierarchy" visible="yes" title="" intro=""/> <tab type="classmembers" visible="yes" title="" intro=""/> </tab> - <tab type="structs" visible="yes" title=""> - <tab type="structlist" visible="yes" title="" intro=""/> - <tab type="structindex" visible="$ALPHABETICAL_INDEX" title=""/> - </tab> - <tab type="exceptions" visible="yes" title=""> - <tab type="exceptionlist" visible="yes" title="" intro=""/> - <tab type="exceptionindex" visible="$ALPHABETICAL_INDEX" title=""/> - <tab type="exceptionhierarchy" visible="yes" title="" intro=""/> - </tab> <tab type="files" visible="yes" title=""> <tab type="filelist" visible="yes" title="" intro=""/> <tab type="globals" visible="yes" title="" intro=""/> @@ -102,13 +88,8 @@ <memberdecl> <nestednamespaces visible="yes" title=""/> <constantgroups visible="yes" title=""/> - <interfaces visible="yes" title=""/> <classes visible="yes" title=""/> - <structs visible="yes" title=""/> - <exceptions visible="yes" title=""/> <typedefs title=""/> - <sequences title=""/> - <dictionaries title=""/> <enums title=""/> <functions title=""/> <variables title=""/> @@ -118,8 +99,6 @@ <memberdef> <inlineclasses title=""/> <typedefs title=""/> - <sequences title=""/> - <dictionaries title=""/> <enums title=""/> <functions title=""/> <variables title=""/> @@ -135,16 +114,11 @@ <includedbygraph visible="$INCLUDED_BY_GRAPH"/> <sourcelink visible="yes"/> <memberdecl> - <interfaces visible="yes" title=""/> <classes visible="yes" title=""/> - <structs visible="yes" title=""/> - <exceptions visible="yes" title=""/> <namespaces visible="yes" title=""/> <constantgroups visible="yes" title=""/> <defines title=""/> <typedefs title=""/> - <sequences title=""/> - <dictionaries title=""/> <enums title=""/> <functions title=""/> <variables title=""/> @@ -155,8 +129,6 @@ <inlineclasses title=""/> <defines title=""/> <typedefs title=""/> - <sequences title=""/> - <dictionaries title=""/> <enums title=""/> <functions title=""/> <variables title=""/> @@ -176,8 +148,6 @@ <classes visible="yes" title=""/> <defines title=""/> <typedefs title=""/> - <sequences title=""/> - <dictionaries title=""/> <enums title=""/> <enumvalues title=""/> <functions title=""/> @@ -197,8 +167,6 @@ <inlineclasses title=""/> <defines title=""/> <typedefs title=""/> - <sequences title=""/> - <dictionaries title=""/> <enums title=""/> <enumvalues title=""/> <functions title=""/> diff --git a/docs/doxygen/producer/DoxygenLayout.xml b/docs/doxygen/producer/DoxygenLayout.xml index 2ca7ee9e5fc434c54c3de821c97e8b14d2e0da8f..99734b3cef7ea26f7e37e390a1de8c18b7c2663d 100644 --- a/docs/doxygen/producer/DoxygenLayout.xml +++ b/docs/doxygen/producer/DoxygenLayout.xml @@ -1,5 +1,5 @@ <doxygenlayout version="1.0"> - <!-- Generated by doxygen 1.8.17 --> + <!-- Generated by doxygen 1.8.11 --> <!-- Navigation index tabs for HTML output --> <navindex> <tab type="user" url="../index.html" visible="yes" title="Main ASAP::O"/> @@ -10,26 +10,12 @@ <tab type="namespacelist" visible="yes" title="" intro=""/> <tab type="namespacemembers" visible="yes" title="" intro=""/> </tab> - <tab type="interfaces" visible="yes" title=""> - <tab type="interfacelist" visible="yes" title="" intro=""/> - <tab type="interfaceindex" visible="$ALPHABETICAL_INDEX" title=""/> - <tab type="interfacehierarchy" visible="yes" title="" intro=""/> - </tab> <tab type="classes" visible="yes" title=""> <tab type="classlist" visible="yes" title="" intro=""/> <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/> <tab type="hierarchy" visible="yes" title="" intro=""/> <tab type="classmembers" visible="yes" title="" intro=""/> </tab> - <tab type="structs" visible="yes" title=""> - <tab type="structlist" visible="yes" title="" intro=""/> - <tab type="structindex" visible="$ALPHABETICAL_INDEX" title=""/> - </tab> - <tab type="exceptions" visible="yes" title=""> - <tab type="exceptionlist" visible="yes" title="" intro=""/> - <tab type="exceptionindex" visible="$ALPHABETICAL_INDEX" title=""/> - <tab type="exceptionhierarchy" visible="yes" title="" intro=""/> - </tab> <tab type="files" visible="yes" title=""> <tab type="filelist" visible="yes" title="" intro=""/> <tab type="globals" visible="yes" title="" intro=""/> @@ -102,13 +88,8 @@ <memberdecl> <nestednamespaces visible="yes" title=""/> <constantgroups visible="yes" title=""/> - <interfaces visible="yes" title=""/> <classes visible="yes" title=""/> - <structs visible="yes" title=""/> - <exceptions visible="yes" title=""/> <typedefs title=""/> - <sequences title=""/> - <dictionaries title=""/> <enums title=""/> <functions title=""/> <variables title=""/> @@ -118,8 +99,6 @@ <memberdef> <inlineclasses title=""/> <typedefs title=""/> - <sequences title=""/> - <dictionaries title=""/> <enums title=""/> <functions title=""/> <variables title=""/> @@ -135,16 +114,11 @@ <includedbygraph visible="$INCLUDED_BY_GRAPH"/> <sourcelink visible="yes"/> <memberdecl> - <interfaces visible="yes" title=""/> <classes visible="yes" title=""/> - <structs visible="yes" title=""/> - <exceptions visible="yes" title=""/> <namespaces visible="yes" title=""/> <constantgroups visible="yes" title=""/> <defines title=""/> <typedefs title=""/> - <sequences title=""/> - <dictionaries title=""/> <enums title=""/> <functions title=""/> <variables title=""/> @@ -155,8 +129,6 @@ <inlineclasses title=""/> <defines title=""/> <typedefs title=""/> - <sequences title=""/> - <dictionaries title=""/> <enums title=""/> <functions title=""/> <variables title=""/> @@ -176,8 +148,6 @@ <classes visible="yes" title=""/> <defines title=""/> <typedefs title=""/> - <sequences title=""/> - <dictionaries title=""/> <enums title=""/> <enumvalues title=""/> <functions title=""/> @@ -197,8 +167,6 @@ <inlineclasses title=""/> <defines title=""/> <typedefs title=""/> - <sequences title=""/> - <dictionaries title=""/> <enums title=""/> <enumvalues title=""/> <functions title=""/> diff --git a/examples/consumer/simple-consumer/CMakeLists.txt b/examples/consumer/simple-consumer/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..99f2a9ee5b9e8de947d4d0b212e7b27b29d73a07 --- /dev/null +++ b/examples/consumer/simple-consumer/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 2.8) + +project(asapo-consume) + +set(CMAKE_CXX_STANDARD 11) + +IF(CMAKE_C_COMPILER_ID STREQUAL "GNU") + SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") +ENDIF() + +find_package (Threads) + +set(TARGET_NAME ${CMAKE_PROJECT_NAME}) + +set(SOURCE_FILES consume.cpp) + +link_directories(asapo/lib) + +add_executable(${TARGET_NAME} ${SOURCE_FILES}) +target_include_directories(${TARGET_NAME} PUBLIC asapo/include) +target_link_libraries(${TARGET_NAME} asapo-consumer curl ${CMAKE_THREAD_LIBS_INIT}) diff --git a/examples/consumer/simple-consumer/consume.cpp b/examples/consumer/simple-consumer/consume.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8df37f0ce6d3f7f81837c25ba62766ea3c3bfaba --- /dev/null +++ b/examples/consumer/simple-consumer/consume.cpp @@ -0,0 +1,35 @@ +#include "asapo_consumer.h" + +void exit_if_error(std::string error_string, const asapo::Error& err) { + if (err) { + std::cerr << error_string << err << std::endl; + exit(EXIT_FAILURE); + } +} + +int main(int argc, char* argv[]) { + asapo::Error err; + + auto endpoint = "asapo-services2:8400"; + auto beamtime = "asapo_test"; + auto token = "KmUDdacgBzaOD3NIJvN1NmKGqWKtx0DK-NyPjdpeWkc="; + + auto broker = asapo::DataBrokerFactory::CreateServerBroker(endpoint, "", true, asapo::SourceCredentials{beamtime, "", "", token}, &err); + exit_if_error("Cannot create consumer", err); + broker->SetTimeout((uint64_t) 1000); + + auto group_id = broker->GenerateNewGroupId(&err); + exit_if_error("Cannot create group id", err); + + asapo::FileInfo fi; + asapo::FileData data; + + err = broker->GetLast(&fi, group_id, &data); + exit_if_error("Cannot get next record", err); + + std::cout << "id: " << fi.id << std::endl; + std::cout << "file name: " << fi.name << std::endl; + std::cout << "file content: " << reinterpret_cast<char const*>(data.get()) << std::endl; + return EXIT_SUCCESS; +} + diff --git a/examples/producer/simple-producer/CMakeLists.txt b/examples/producer/simple-producer/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..9a5e097aec62e79ed1dc7b9d19b38a3342d3bc3e --- /dev/null +++ b/examples/producer/simple-producer/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 2.8) + +project(asapo-produce) + +set(CMAKE_CXX_STANDARD 11) + +IF(CMAKE_C_COMPILER_ID STREQUAL "GNU") + SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") +ENDIF() + +find_package (Threads) + +set(TARGET_NAME ${CMAKE_PROJECT_NAME}) + +set(SOURCE_FILES produce.cpp) + +link_directories(asapo/lib) + +add_executable(${TARGET_NAME} ${SOURCE_FILES}) +target_include_directories(${TARGET_NAME} PUBLIC asapo/include) +target_link_libraries(${TARGET_NAME} asapo-producer curl ${CMAKE_THREAD_LIBS_INIT}) diff --git a/examples/producer/simple-producer/produce.cpp b/examples/producer/simple-producer/produce.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c1f850bc0c428a66cac85dcdc92e8b8942b23bb1 --- /dev/null +++ b/examples/producer/simple-producer/produce.cpp @@ -0,0 +1,46 @@ +#include "asapo_producer.h" + +void ProcessAfterSend(asapo::GenericRequestHeader header, asapo::Error err) { + if (err) { + std::cerr << "error/warnign during send: " << err << std::endl; + return; + } else { + std::cout << "successfuly send " << header.Json() << std::endl; + return; + } +} + + +void exit_if_error(std::string error_string, const asapo::Error& err) { + if (err) { + std::cerr << error_string << err << std::endl; + exit(EXIT_FAILURE); + } +} + + +int main(int argc, char* argv[]) { + asapo::Error err; + + auto source = "asapo-services2:8400"; + auto beamtime = "asapo_test"; + + auto producer = asapo::Producer::Create(source, 1,asapo::RequestHandlerType::kTcp, + asapo::SourceCredentials{beamtime, "", "", ""}, 60, &err); + exit_if_error("Cannot start producer", err); + + std::string to_send = "hello"; + auto send_size = to_send.size() + 1; + auto buffer = asapo::FileData(new uint8_t[send_size]); + memcpy(buffer.get(),to_send.c_str(),send_size); + + asapo::EventHeader event_header{1, send_size, "test_file"}; + err = producer->SendData(event_header, std::move(buffer), asapo::kDefaultIngestMode, &ProcessAfterSend); + exit_if_error("Cannot send file", err); + + err = producer->WaitRequestsFinished(1000); + exit_if_error("Producer exit on timeout", err); + + return EXIT_SUCCESS; +} +