Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNMY] Reworking #19

Open
wants to merge 25 commits into
base: release/IPM-2.6.0
Choose a base branch
from

Conversation

ericclappier-eaton
Copy link

No description provided.

//catch (const std::exception& e) {
// logWarn("m_promiseReceiver error: {}", e.what());
//}
//m_promiseReceiver.setValue();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove it, this comment?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I let this comment because if we wanted to restore the wait on a stop, we know that there is an issue ...

}

bool AmqpClient::isConnected() {
// Wait communication was restored
// test if connected
return (m_connection && m_connection.active() && connected() == ComState::Connected);
}

ComState AmqpClient::connected()
{
//logTrace("AmqpClient::connected m_communicationState={}", m_communicationState);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take into account

@@ -20,9 +20,10 @@
#pragma once

#include "MsgBusAmqpUtils.h"
#include "../../utils/public_include/fty/messagebus2/utils/MsgBusPoolWorker.hpp"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this and not "MsgBusPoolWorker.hpp" and in cmake add the right line?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, don't understand, it doesn't compile in my side ... I will try again

return fty::unexpected(DeliveryState::Unavailable);
}

if (!m_clientPtr) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one can be factorized with isServiceAvailable(), isn't it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been made yet in AmqpClient

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean why do you test m_clientPtr after, if the test is done inside isServiceAvailable, the line 72 is redundant

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I change this

logDebug("Sending message ...");
proton::message msgToSend = getAmqpMessage(message);

if (!m_clientPtr) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same like above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been made yet in AmqpClient

}

const std::string& MessageBusAmqp::clientName() const noexcept
{
return m_busAmqp->clientName();
return m_clientName;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the MsgBusAmqp, it's was a file (encapsulation) for fty, etn to check if the message was ok, or not, if a client want to bypass some part, he can call directly MessageBusAmqp.cpp (and h)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it complicate a little the code but the first reason that I wanted to have the same class for Promise in common. With this class, it would be impossible ...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but you remove this functionnality

bool PromiseBase<T>::isReady() {
bool res = false;
if (m_future.valid()) {
//auto r = m_future.wait_for(std::chrono::seconds(0));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to remove

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take into account

bool PromiseBase<T>::waitFor(const int& timeout_ms) {
return (
isReady() &&
m_future.wait_for(std::chrono::duration<int,std::milli>(timeout_ms)) == std::future_status::ready
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ident

void setValue(const Message& m);

MessageBus& m_messageBus; // message bus instance
std::string m_queue; // queue where the reply should arrive
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address insteafof m_queue (i.e. Address m_address);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take into account

void Promise<Message>::setValue(const Message& m) {
if (this->isReady()) {
this->m_promise.set_value(m);
//return {};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to remove

Copy link
Author

@ericclappier-eaton ericclappier-eaton Jul 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to remember that it is not possible in this case

void reset();
bool waitFor(const int& timeout_ms);

public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

Copy link
Author

@ericclappier-eaton ericclappier-eaton Jul 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken into account

//fty::Expected<void> setValue(const Message& m);
void setValue(const Message& m);

MessageBus& m_messageBus; // message bus instance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private members with accessors?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken into account


template <typename T>
PromiseBase<T>::PromiseBase() {
m_future = m_promise.get_future();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming: getFuture?

Promise<Message>::~Promise() {
if(!m_address.empty()) {
m_messageBus.unreceive(m_address);
m_address = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be: m_address.clear()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants