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

Improvements #214

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ if (MSVC)
set(MORE_LIBRARIES ws2_32 Rpcrt4 Iphlpapi)
endif()

# specific case of windows UWP
if( ${CMAKE_SYSTEM_NAME} STREQUAL "WindowsStore" AND ${CMAKE_SYSTEM_VERSION} STREQUAL "10.0")
ADD_DEFINITIONS(-DZMQ_HAVE_WINDOWS_UWP)
ADD_DEFINITIONS(-D_WIN32_WINNT=_WIN32_WINNT_WIN10)
endif()


# required libraries for mingw
if (MINGW)
set(MORE_LIBRARIES -lws2_32 -lrpcrt4 -liphlpapi)
Expand Down Expand Up @@ -163,7 +170,13 @@ set_target_properties(mlm
PROPERTIES DEFINE_SYMBOL "MLM_EXPORTS"
)
set_target_properties (mlm
PROPERTIES SOVERSION "1.0.1"
PROPERTIES SOVERSION "1"
)
target_link_libraries(mlm
${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES}
)
set_target_properties (mlm
PROPERTIES VERSION "1.1.0"
)
target_link_libraries(mlm
${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES}
Expand Down Expand Up @@ -303,6 +316,7 @@ foreach(TEST_CLASS ${TEST_CLASSES})
add_test(
NAME ${TEST_CLASS}
COMMAND mlm_selftest --continue --verbose --test ${TEST_CLASS}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
set_tests_properties(
${TEST_CLASS}
Expand Down
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ EXTRA_DIST += \
endif

EXTRA_DIST += \
bindings \
src/mlm_server_engine.inc \
src/mlm_client_engine.inc \
src/mlm_client_custom.xml \
Expand Down
11 changes: 3 additions & 8 deletions api/mlm_client.api
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@
<return type = "integer" />
</method>

<method name = "set producer">
Prepare to publish to a specified stream. After this, all messages are sent to
this stream exclusively.
Returns >= 0 if successful, -1 if interrupted.
<argument name = "stream" type = "string"></argument>
<return type = "integer" />
</method>

<method name = "set consumer">
Consume messages with matching subjects. The pattern is a regular expression
using the CZMQ zrex syntax. The most useful elements are: ^ and $ to match the
Expand All @@ -104,6 +96,7 @@
<method name = "send">
Send STREAM SEND message to server, takes ownership of message
and destroys message when done sending it.
<argument name = "address" type = "string">Stream address</argument>
<argument name = "subject" type = "string">Message subject</argument>
<argument name = "content" type = "zmsg" by_reference = "1">Message body frames</argument>
<return type = "integer" />
Expand Down Expand Up @@ -184,6 +177,7 @@
<method name = "sendx">
Send multipart string message to stream, end list with NULL
Returns 0 if OK, -1 if failed due to lack of memory or other error.
<argument name = "address" type = "string" />
<argument name = "subject" type = "string" />
<argument name = "content" type = "string" variadic = "1" />
<return type = "integer" />
Expand Down Expand Up @@ -215,6 +209,7 @@
of string contents received, or -1 in case of error. Free the returned
subject and content strings when finished with them. To get the type of
the command, use mlm_client_command ().
<argument name = "address_p" type = "string" by_reference = "1" />
<argument name = "subject_p" type = "string" by_reference = "1" />
<argument name = "string_p" type = "string" by_reference = "1" variadic = "1" />
<return type = "integer" />
Expand Down
1 change: 0 additions & 1 deletion api/mlm_proto.api
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<constant name = "connection_ping" value = "2" />
<constant name = "connection_pong" value = "3" />
<constant name = "connection_close" value = "4" />
<constant name = "stream_write" value = "5" />
<constant name = "stream_read" value = "6" />
<constant name = "stream_send" value = "7" />
<constant name = "stream_deliver" value = "8" />
Expand Down
21 changes: 8 additions & 13 deletions bindings/jni/src/main/c/org_zeromq_mlm_MlmClient.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ Java_org_zeromq_mlm_MlmClient__1_1connect (JNIEnv *env, jclass c, jlong self, js
return connect_;
}

JNIEXPORT jint JNICALL
Java_org_zeromq_mlm_MlmClient__1_1setProducer (JNIEnv *env, jclass c, jlong self, jstring stream)
{
char *stream_ = (char *) (*env)->GetStringUTFChars (env, stream, NULL);
jint set_producer_ = (jint) mlm_client_set_producer ((mlm_client_t *) (intptr_t) self, stream_);
(*env)->ReleaseStringUTFChars (env, stream, stream_);
return set_producer_;
}

JNIEXPORT jint JNICALL
Java_org_zeromq_mlm_MlmClient__1_1setConsumer (JNIEnv *env, jclass c, jlong self, jstring stream, jstring pattern)
{
Expand All @@ -100,10 +91,12 @@ Java_org_zeromq_mlm_MlmClient__1_1setWorker (JNIEnv *env, jclass c, jlong self,
}

JNIEXPORT jint JNICALL
Java_org_zeromq_mlm_MlmClient__1_1send (JNIEnv *env, jclass c, jlong self, jstring subject, jlong content)
Java_org_zeromq_mlm_MlmClient__1_1send (JNIEnv *env, jclass c, jlong self, jstring address, jstring subject, jlong content)
{
char *address_ = (char *) (*env)->GetStringUTFChars (env, address, NULL);
char *subject_ = (char *) (*env)->GetStringUTFChars (env, subject, NULL);
jint send_ = (jint) mlm_client_send ((mlm_client_t *) (intptr_t) self, subject_, (zmsg_t **) (intptr_t) &content);
jint send_ = (jint) mlm_client_send ((mlm_client_t *) (intptr_t) self, address_, subject_, (zmsg_t **) (intptr_t) &content);
(*env)->ReleaseStringUTFChars (env, address, address_);
(*env)->ReleaseStringUTFChars (env, subject, subject_);
return send_;
}
Expand Down Expand Up @@ -204,11 +197,13 @@ Java_org_zeromq_mlm_MlmClient__1_1tracker (JNIEnv *env, jclass c, jlong self)
}

JNIEXPORT jint JNICALL
Java_org_zeromq_mlm_MlmClient__1_1sendx (JNIEnv *env, jclass c, jlong self, jstring subject, jstring content)
Java_org_zeromq_mlm_MlmClient__1_1sendx (JNIEnv *env, jclass c, jlong self, jstring address, jstring subject, jstring content)
{
char *address_ = (char *) (*env)->GetStringUTFChars (env, address, NULL);
char *subject_ = (char *) (*env)->GetStringUTFChars (env, subject, NULL);
char *content_ = (char *) (*env)->GetStringUTFChars (env, content, NULL);
jint sendx_ = (jint) mlm_client_sendx ((mlm_client_t *) (intptr_t) self, subject_, content_);
jint sendx_ = (jint) mlm_client_sendx ((mlm_client_t *) (intptr_t) self, address_, subject_, content_);
(*env)->ReleaseStringUTFChars (env, address, address_);
(*env)->ReleaseStringUTFChars (env, subject, subject_);
(*env)->ReleaseStringUTFChars (env, content, content_);
return sendx_;
Expand Down
21 changes: 6 additions & 15 deletions bindings/jni/src/main/java/org/zeromq/mlm/MlmClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,6 @@ public int connect (String endpoint, int timeout, String address) {
return __connect (self, endpoint, timeout, address);
}
/*
Prepare to publish to a specified stream. After this, all messages are sent to
this stream exclusively.
Returns >= 0 if successful, -1 if interrupted.
*/
native static int __setProducer (long self, String stream);
public int setProducer (String stream) {
return __setProducer (self, stream);
}
/*
Consume messages with matching subjects. The pattern is a regular expression
using the CZMQ zrex syntax. The most useful elements are: ^ and $ to match the
start and end, . to match any character, \s and \S to match whitespace and
Expand All @@ -121,9 +112,9 @@ public int setWorker (String address, String pattern) {
Send STREAM SEND message to server, takes ownership of message
and destroys message when done sending it.
*/
native static int __send (long self, String subject, long content);
public int send (String subject, Zmsg content) {
return __send (self, subject, content.self);
native static int __send (long self, String address, String subject, long content);
public int send (String address, String subject, Zmsg content) {
return __send (self, address, subject, content.self);
}
/*
Send MAILBOX SEND message to server, takes ownership of message
Expand Down Expand Up @@ -211,9 +202,9 @@ public String tracker () {
Send multipart string message to stream, end list with NULL
Returns 0 if OK, -1 if failed due to lack of memory or other error.
*/
native static int __sendx (long self, String subject, String content);
public int sendx (String subject, String content []) {
return __sendx (self, subject, content [0]);
native static int __sendx (long self, String address, String subject, String content);
public int sendx (String address, String subject, String content []) {
return __sendx (self, address, subject, content [0]);
}
/*
Send multipart string to mailbox, end list with NULL
Expand Down
12 changes: 3 additions & 9 deletions bindings/lua_ffi/malamute_ffi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,6 @@ int
int
mlm_client_connect (mlm_client_t *self, const char *endpoint, uint32_t timeout, const char *address);

// Prepare to publish to a specified stream. After this, all messages are sent to
// this stream exclusively.
// Returns >= 0 if successful, -1 if interrupted.
int
mlm_client_set_producer (mlm_client_t *self, const char *stream);

// Consume messages with matching subjects. The pattern is a regular expression
// using the CZMQ zrex syntax. The most useful elements are: ^ and $ to match the
// start and end, . to match any character, \s and \S to match whitespace and
Expand All @@ -232,7 +226,7 @@ int
// Send STREAM SEND message to server, takes ownership of message
// and destroys message when done sending it.
int
mlm_client_send (mlm_client_t *self, const char *subject, zmsg_t **content);
mlm_client_send (mlm_client_t *self, const char *address, const char *subject, zmsg_t **content);

// Send MAILBOX SEND message to server, takes ownership of message
// and destroys message when done sending it.
Expand Down Expand Up @@ -286,7 +280,7 @@ const char *
// Send multipart string message to stream, end list with NULL
// Returns 0 if OK, -1 if failed due to lack of memory or other error.
int
mlm_client_sendx (mlm_client_t *self, const char *subject, const char *content, ...);
mlm_client_sendx (mlm_client_t *self, const char *address, const char *subject, const char *content, ...);

// Send multipart string to mailbox, end list with NULL
// Returns 0 if OK, -1 if failed due to lack of memory or other error.
Expand All @@ -306,7 +300,7 @@ int
// subject and content strings when finished with them. To get the type of
// the command, use mlm_client_command ().
int
mlm_client_recvx (mlm_client_t *self, char **subject_p, char **string_p, ...);
mlm_client_recvx (mlm_client_t *self, char **address_p, char **subject_p, char **string_p, ...);

// Enable verbose tracing (animation) of state machine activity.
void
Expand Down
17 changes: 0 additions & 17 deletions bindings/nodejs/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ NAN_MODULE_INIT (MlmClient::Init) {
Nan::SetPrototypeMethod (tpl, "connected", _connected);
Nan::SetPrototypeMethod (tpl, "setPlainAuth", _set_plain_auth);
Nan::SetPrototypeMethod (tpl, "connect", _connect);
Nan::SetPrototypeMethod (tpl, "setProducer", _set_producer);
Nan::SetPrototypeMethod (tpl, "setConsumer", _set_consumer);
Nan::SetPrototypeMethod (tpl, "setWorker", _set_worker);
Nan::SetPrototypeMethod (tpl, "send", _send);
Expand Down Expand Up @@ -369,22 +368,6 @@ NAN_METHOD (MlmClient::_connect) {
info.GetReturnValue ().Set (Nan::New<Number>(result));
}

NAN_METHOD (MlmClient::_set_producer) {
MlmClient *mlm_client = Nan::ObjectWrap::Unwrap <MlmClient> (info.Holder ());
char *stream;
if (info [0]->IsUndefined ())
return Nan::ThrowTypeError ("method requires a `stream`");
else
if (!info [0]->IsString ())
return Nan::ThrowTypeError ("`stream` must be a string");
else {
Nan::Utf8String stream_utf8 (info [0].As<String>());
stream = *stream_utf8;
}
int result = mlm_client_set_producer (mlm_client->self, (const char *)stream);
info.GetReturnValue ().Set (Nan::New<Number>(result));
}

NAN_METHOD (MlmClient::_set_consumer) {
MlmClient *mlm_client = Nan::ObjectWrap::Unwrap <MlmClient> (info.Holder ());
char *stream;
Expand Down
1 change: 0 additions & 1 deletion bindings/nodejs/binding.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class MlmClient: public Nan::ObjectWrap {
static NAN_METHOD (_connected);
static NAN_METHOD (_set_plain_auth);
static NAN_METHOD (_connect);
static NAN_METHOD (_set_producer);
static NAN_METHOD (_set_consumer);
static NAN_METHOD (_set_worker);
static NAN_METHOD (_send);
Expand Down
7 changes: 0 additions & 7 deletions bindings/python/malamute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ def connect(self, endpoint, timeout, address):
"Could not connect to malamute server at {!r}", endpoint,
)

def set_producer(self, stream):
result = self.c.set_producer(stream)
self._check_error(
result,
"Could not set producer",
)

def set_worker(self, address, pattern):
result = self.c.set_worker(address, pattern)
self._check_error(
Expand Down
Loading