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

Request-reply (Client-Server) support #219

Merged
merged 16 commits into from
Jul 28, 2017
Merged

Request-reply (Client-Server) support #219

merged 16 commits into from
Jul 28, 2017

Conversation

eile
Copy link
Contributor

@eile eile commented Jul 18, 2017

No description provided.

Copy link

@hernando hernando left a comment

Choose a reason for hiding this comment

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

Only first commit reviewed

using ContextPtr = std::shared_ptr<void>;

/** @return the current ZeroMQ context. Users need to hold onto this context to
* extend its lifetime to all sockets created from the context.

Choose a reason for hiding this comment

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

This documentation is not precise. The context is created if it doesn't exist.

This function is a bit strange for such a simple name as getContext.
Why storing a weak reference to the context internally? It seems as if you wanted to guarantee that all sockets will share the same context implicitly as long there's one object holding a context and remove the context once the last object using it is destroyed. If that's the intention it should be documented somewhere. I would rename it to getOrCreateSharedContext()

@eile eile force-pushed the reqrep branch 2 times, most recently from c6b2358 to 2333a50 Compare July 19, 2017 14:05
tests/reqRep.cpp Outdated
BOOST_CHECK(handled);
}

#if 0

Choose a reason for hiding this comment

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

Isn't there a better way to skip tests that are not ready with Boost.UnitTest? At least In Python there's a decorator to do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's gone now.

tests/reqRep.cpp Outdated
std::thread thread([&] { runOnce(server, echo); });

bool handled = false;
client.get(echo.getTypeIdentifier(), [&](const void* data,

Choose a reason for hiding this comment

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

Is there any difference between using echo.getTypeIndenitifier() and test::Echo::IDENTIFIER?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The first can be called from the object without knowing it's type, and the second one is static and can be called without an instance (but needs the type)

tests/reqRep.cpp Outdated
zeroeq::Server noServer(client.getSession());
zeroeq::detail::Sender::getUUID() =
servus::make_UUID(); // different machine
zeroeq::Server server(client.getSession());

Choose a reason for hiding this comment

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

Can you explain this a little better. Rename noServer to notConnected or unreachable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's gone. I started with a c&p from the pubsub tests

tests/reqRep.cpp Outdated
std::thread thread([&] { runOnce(server, echo); });

bool handled = false;
client.get(echo.getTypeIdentifier(), [&](const void* data,

Choose a reason for hiding this comment

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

This is something that was not clearly specified in the feature request. Client get/set methods were mentioned, but only in a example, and the example doesn't match this test. What's the value of this get method over Client::request, because I don't see many differences.

tests/reqRep.cpp Outdated
received = true;
break;
}
}

Choose a reason for hiding this comment

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

I'm confused. Isn't this for request/reply tests? Why Client has a method called publish? Why servers has a subscribe method? This doesn't resemble the feature spec at all.

I think I see. You just copied the test from pubSub and "commented" this part. If the partial commits don't make sense it's a waste of time to look into them, but looking at the full pull request at once is really hard because of its size. What should I expect from the rest of the commits and what can I expect to be less time consuming? I was already feeling this PR was going to be hard to review and this commit hasn't improved that feeling.

@eile eile force-pushed the reqrep branch 2 times, most recently from 31f92ed to fa62b74 Compare July 19, 2017 14:24
zeroeq/client.h Outdated
* once the servers are available.
*
* A receive on any instance of a shared group will work on all instance
* and call the registered handlers.

Choose a reason for hiding this comment

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

Rephrase this sentence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

zeroeq/client.h Outdated
size_t size, ReplyFunc& func);

/** @return the session name that is used for filtering. */
ZEROEQ_API const std::string& getSession() const;

Choose a reason for hiding this comment

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

Should this method be in Receiver?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Monitor is a session-less receiver.

zeroeq/client.h Outdated
ReplyFunc& func);

/**
* Request the execution of the given data on a connected Server.

Choose a reason for hiding this comment

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

"Request the execution of data", that's a funny sentence

* Request the execution of the given data on a connected Server.
*
* The reply function will be executed during receive(). May block of when
* all servers are overloaded or no server is connected.

Choose a reason for hiding this comment

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

block of, remove of

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* Request the execution of the given data on a connected Server.
*
* The reply function will be executed during receive(). May block of when
* all servers are overloaded or no server is connected.

Choose a reason for hiding this comment

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

Is it true that this function may block (and same for the other overload)? Isn't receive the function that blocks?
If this function can block, then it should accept a timeout parameter or at least there should be a way to interrupt it.
How does zeromq work with REQ/REP sockets anyway? To me it seems a bit odd to make requests to an inexistent resource. I'm also missing a way to know that the client is connected to any server without having to use application level messages for that. It's also not clear to me whether a user may want to have a client which is not connected to anything after the constructors return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's true since the request sending will block. Receive() will block on at least one reception of a reply.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would add a timeout on an as-needed basis. One needs to use ZMQ_DONTWAIT and spin, afaik. In reality I expect this to be a non-issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One can connect to a zeroconf session which will dynamically update the servers as they are available. The Monitor can be used to get notifications.

eile pushed a commit to eile/ZeroEQ that referenced this pull request Jul 20, 2017
eile pushed a commit to eile/ZeroEQ that referenced this pull request Jul 20, 2017
@eile eile force-pushed the reqrep branch 2 times, most recently from f41d03d to 8ea075a Compare July 20, 2017 12:29
@eile
Copy link
Contributor Author

eile commented Jul 20, 2017

Retest this please.

1 similar comment
@eile
Copy link
Contributor Author

eile commented Jul 21, 2017

Retest this please.

eile pushed a commit to eile/ZeroEQ that referenced this pull request Jul 21, 2017
eile pushed a commit to eile/ZeroEQ that referenced this pull request Jul 24, 2017
eile pushed a commit to eile/ZeroEQ that referenced this pull request Jul 24, 2017
eile pushed a commit to eile/ZeroEQ that referenced this pull request Jul 27, 2017
eile pushed a commit to eile/ZeroEQ that referenced this pull request Jul 27, 2017
eile pushed a commit to eile/ZeroEQ that referenced this pull request Jul 28, 2017
@eile
Copy link
Contributor Author

eile commented Jul 28, 2017

Retest this please.

@eile
Copy link
Contributor Author

eile commented Jul 28, 2017

ping?

@eile eile merged commit 696a15d into HBPVIS:master Jul 28, 2017
@eile eile deleted the reqrep branch July 28, 2017 12:31
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