You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by GitBox <gi...@apache.org> on 2020/02/24 10:17:30 UTC

[GitHub] [celix] abroekhuis opened a new pull request #156: Added protocol service API and wire protocol implementation to be use…

abroekhuis opened a new pull request #156: Added protocol service API and wire protocol implementation to be use…
URL: https://github.com/apache/celix/pull/156
 
 
   …d by admin (sender/receiver). Actual used service is matched, similar to serializer.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [celix] pnoltes commented on a change in pull request #156: Added protocol service API and wire protocol implementation to be use…

Posted by GitBox <gi...@apache.org>.
pnoltes commented on a change in pull request #156: Added protocol service API and wire protocol implementation to be use…
URL: https://github.com/apache/celix/pull/156#discussion_r388178500
 
 

 ##########
 File path: bundles/pubsub/pubsub_protocol_wire_v1/src/pubsub_wire_protocol_impl.c
 ##########
 @@ -0,0 +1,309 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+
+#include "utils.h"
+#include "celix_properties.h"
+
+#include "pubsub_wire_protocol_impl.h"
+#include "pubsub_wire_protocol_common.h"
+
+#define NETSTRING_ERROR_TOO_LONG     -1
+#define NETSTRING_ERROR_NO_COLON     -2
+#define NETSTRING_ERROR_TOO_SHORT    -3
+#define NETSTRING_ERROR_NO_COMMA     -4
+#define NETSTRING_ERROR_LEADING_ZERO -5
+#define NETSTRING_ERROR_NO_LENGTH    -6
+
+struct pubsub_protocol_wire_v1 {
+};
+
+static celix_status_t pubsubProtocol_createNetstring(const char* string, char** netstringOut);
+static int pubsubProtocol_parseNetstring(char *buffer, size_t buffer_length,
+                                  char **netstring_start, size_t *netstring_length);
+
+celix_status_t pubsubProtocol_create(pubsub_protocol_wire_v1_t **protocol) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    *protocol = calloc(1, sizeof(**protocol));
+
+    if (!*protocol) {
+        status = CELIX_ENOMEM;
+    }
+    else {
+        //
+    }
+
+    return status;
+}
+
+celix_status_t pubsubProtocol_destroy(pubsub_protocol_wire_v1_t* protocol) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    free(protocol);
+
+    return status;
+}
+
+celix_status_t pubsubProtocol_getSyncHeader(void* handle, void *syncHeader) {
+    for (int i = 0; i < 5; ++i) {
+        ((char *) syncHeader)[i] = '\0';
+    }
+    writeInt(syncHeader, 0, PROTOCOL_WIRE_SYNC);
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t pubsubProtocol_encodeHeader(void *handle, pubsub_protocol_message_t *message, void **outBuffer, size_t *outLength) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    *outBuffer = calloc(1, 24);
+    if (*outBuffer == NULL) {
+        status = CELIX_ENOMEM;
+    } else {
+        int idx = 0;
+        idx = writeInt(*outBuffer, idx, PROTOCOL_WIRE_SYNC);
+        idx = writeInt(*outBuffer, idx, PROTOCOL_WIRE_ENVELOPE_VERSION);
+        idx = writeInt(*outBuffer, idx, message->header.msgId);
+        idx = writeShort(*outBuffer, idx, message->header.msgMajorVersion);
+        idx = writeShort(*outBuffer, idx, message->header.msgMinorVersion);
+        idx = writeInt(*outBuffer, idx, message->header.payloadSize);
+        idx = writeInt(*outBuffer, idx, message->header.metadataSize);
+
+        *outLength = idx;
+    }
+
+    return status;
+}
+
+celix_status_t pubsubProtocol_encodePayload(void *handle, pubsub_protocol_message_t *message, void **outBuffer, size_t *outLength) {
+    *outBuffer = message->payload.payload;
+    *outLength = message->payload.length;
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t pubsubProtocol_encodeMetadata(void *handle, pubsub_protocol_message_t *message, void **outBuffer, size_t *outLength) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    char *line = calloc(1, 4);
+    size_t idx = 4;
+    size_t len = 0;
+
+    const char *key;
+    if (message->metadata.metadata != NULL && celix_properties_size(message->metadata.metadata) > 0) {
+        CELIX_PROPERTIES_FOR_EACH(message->metadata.metadata, key) {
+            const char *val = celix_properties_get(message->metadata.metadata, key, "!Error!");
+            char *keyNetString = NULL;
+            char *valueNetString = NULL;
+
+            status = pubsubProtocol_createNetstring(key, &keyNetString);
+            if (status != CELIX_SUCCESS) {
+                break;
+            }
+            status = pubsubProtocol_createNetstring(val, &valueNetString);
+            if (status != CELIX_SUCCESS) {
+                break;
+            }
+
+            len += strlen(keyNetString);
+            len += strlen(valueNetString);
+            char *tmp = realloc(line, len + sizeof(uint32_t));
+            if (!tmp) {
+                free(line);
+                status = CELIX_ENOMEM;
+                return status;
+            }
+            line = tmp;
+
+            memcpy(line + idx, keyNetString, strlen(keyNetString));
+            idx += strlen(keyNetString);
+            memcpy(line + idx, valueNetString, strlen(keyNetString));
+            idx += strlen(valueNetString);
+
+            free(keyNetString);
+            free(valueNetString);
+        }
+    }
+    int size = celix_properties_size(message->metadata.metadata);
+    memcpy(line, &size, sizeof(int32_t));
+
+    *outBuffer = line;
+    *outLength = idx;
+
+    return status;
+}
+
+celix_status_t pubsubProtocol_decodeHeader(void* handle, void *data, size_t length, pubsub_protocol_message_t *message) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    int idx = 0;
+    unsigned int sync;
+    idx = readInt(data, idx, &sync);
+    if (sync != PROTOCOL_WIRE_SYNC) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    } else {
+        unsigned int envelopeVersion;
+        idx = readInt(data, idx, &envelopeVersion);
+        if (envelopeVersion != PROTOCOL_WIRE_ENVELOPE_VERSION) {
+            status = CELIX_ILLEGAL_ARGUMENT;
+        } else {
+            idx = readInt(data, idx, &message->header.msgId);
+            idx = readShort(data, idx, &message->header.msgMajorVersion);
+            idx = readShort(data, idx, &message->header.msgMinorVersion);
+            idx = readInt(data, idx, &message->header.payloadSize);
+            readInt(data, idx, &message->header.metadataSize);
+        }
+    }
+
+    return status;
+}
+
+celix_status_t pubsubProtocol_decodePayload(void* handle, void *data, size_t length, pubsub_protocol_message_t *message){
+    message->payload.payload = data;
+    message->payload.length = length;
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t pubsubProtocol_decodeMetadata(void* handle, void *data, size_t length, pubsub_protocol_message_t *message) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    uint32_t nOfElements;
+    size_t idx = readInt(data, 0, &nOfElements);
+    char *netstring = data + idx;
+    int netstringLen = length - idx;
+
+    message->metadata.metadata = celix_properties_create();
+    while (idx < length) {
+        size_t outlen;
+        status = pubsubProtocol_parseNetstring(netstring, netstringLen, &netstring, &outlen);
+        if (status != CELIX_SUCCESS) {
+            break;
+        }
+        char *key = strndup(netstring, outlen);
+        netstring += outlen + 1;
+        idx += outlen + 3;
+
+        status = pubsubProtocol_parseNetstring(netstring, netstringLen, &netstring, &outlen);
+        if (status != CELIX_SUCCESS) {
+            break;
+        }
+        char *value = strndup(netstring, outlen);
+        netstring += outlen + 1;
+        idx += outlen + 3;
+
+        celix_properties_setWithoutCopy(message->metadata.metadata, key, value);
+    }
+
+    return status;
+}
+
+static celix_status_t pubsubProtocol_createNetstring(const char* string, char** netstringOut) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    size_t str_len = strlen(string);
+    if (str_len == 0) {
+        // 0:,
+        *netstringOut = calloc(1, 4);
+        if (*netstringOut == NULL) {
+            status = CELIX_ENOMEM;
+        } else {
+            *netstringOut[0] = '0';
+            *netstringOut[1] = ':';
+            *netstringOut[2] = ',';
+            *netstringOut[3] = '\0';
+        }
+    } else {
+        size_t numlen = ceil(log10(str_len + 1));
+        *netstringOut = calloc(1, numlen + str_len + 3);
+        if (*netstringOut == NULL) {
+            status = CELIX_ENOMEM;
+        } else {
+            sprintf(*netstringOut, "%zu:%s,", str_len, string);
+        }
+    }
+
+    return status;
+}
+
+/* Reads a netstring from a `buffer` of length `buffer_length`. Writes
 
 Review comment:
   Update LICENSE file?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [celix] pnoltes commented on issue #156: Added protocol service API and wire protocol implementation to be use…

Posted by GitBox <gi...@apache.org>.
pnoltes commented on issue #156: Added protocol service API and wire protocol implementation to be use…
URL: https://github.com/apache/celix/pull/156#issuecomment-590484936
 
 
   The build is failing:
   
   /home/travis/build/apache/celix/bundles/pubsub/test/test/loopback_activator.c: In function ‘bnd_start’:
   948/home/travis/build/apache/celix/bundles/pubsub/test/test/loopback_activator.c:60:23: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
   949   act->subSvc.receive = tst_receive;
   
   probably due to a changed signature of the subriber service functions. 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [celix] abroekhuis commented on a change in pull request #156: Added protocol service API and wire protocol implementation to be use…

Posted by GitBox <gi...@apache.org>.
abroekhuis commented on a change in pull request #156: Added protocol service API and wire protocol implementation to be use…
URL: https://github.com/apache/celix/pull/156#discussion_r388199286
 
 

 ##########
 File path: bundles/pubsub/pubsub_spi/include/pubsub_protocol.h
 ##########
 @@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef PUBSUB_PROTOCOL_SERVICE_H_
+#define PUBSUB_PROTOCOL_SERVICE_H_
+
+#include "celix_properties.h"
+
+#define PUBSUB_PROTOCOL_SERVICE_NAME      "pubsub_protocol"
+#define PUBSUB_PROTOCOL_SERVICE_VERSION   "1.0.0"
+#define PUBSUB_PROTOCOL_SERVICE_RANGE     "[1,2)"
+
+typedef struct pubsub_protocol_header pubsub_protocol_header_t;
+
+struct pubsub_protocol_header {
+    unsigned int msgId;
+    unsigned short msgMajorVersion;
+    unsigned short msgMinorVersion;
+
+    unsigned int payloadSize;
+    unsigned int metadataSize;
+};
+
+typedef struct pubsub_protocol_payload pubsub_protocol_payload_t;
+
+struct pubsub_protocol_payload {
+    void *payload;
+    size_t length;
+};
+
+typedef struct pubsub_protocol_metadata pubsub_protocol_metadata_t;
+
+struct pubsub_protocol_metadata {
+    celix_properties_t *metadata;
+};
+
+typedef struct pubsub_protocol_message pubsub_protocol_message_t;
+
+struct pubsub_protocol_message {
+    pubsub_protocol_header_t header;
+    pubsub_protocol_payload_t payload;
+    pubsub_protocol_metadata_t metadata;
+};
+
+typedef struct pubsub_protocol_service {
+    void* handle;
+
+    celix_status_t (*getSyncHeader)(void *handle, void *sync);
 
 Review comment:
   Added.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [celix] abroekhuis commented on a change in pull request #156: Added protocol service API and wire protocol implementation to be use…

Posted by GitBox <gi...@apache.org>.
abroekhuis commented on a change in pull request #156: Added protocol service API and wire protocol implementation to be use…
URL: https://github.com/apache/celix/pull/156#discussion_r388199184
 
 

 ##########
 File path: bundles/pubsub/pubsub_protocol_wire_v1/src/pubsub_wire_protocol_impl.c
 ##########
 @@ -0,0 +1,309 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+
+#include "utils.h"
+#include "celix_properties.h"
+
+#include "pubsub_wire_protocol_impl.h"
+#include "pubsub_wire_protocol_common.h"
+
+#define NETSTRING_ERROR_TOO_LONG     -1
+#define NETSTRING_ERROR_NO_COLON     -2
+#define NETSTRING_ERROR_TOO_SHORT    -3
+#define NETSTRING_ERROR_NO_COMMA     -4
+#define NETSTRING_ERROR_LEADING_ZERO -5
+#define NETSTRING_ERROR_NO_LENGTH    -6
+
+struct pubsub_protocol_wire_v1 {
+};
+
+static celix_status_t pubsubProtocol_createNetstring(const char* string, char** netstringOut);
+static int pubsubProtocol_parseNetstring(char *buffer, size_t buffer_length,
+                                  char **netstring_start, size_t *netstring_length);
+
+celix_status_t pubsubProtocol_create(pubsub_protocol_wire_v1_t **protocol) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    *protocol = calloc(1, sizeof(**protocol));
+
+    if (!*protocol) {
+        status = CELIX_ENOMEM;
+    }
+    else {
+        //
+    }
+
+    return status;
+}
+
+celix_status_t pubsubProtocol_destroy(pubsub_protocol_wire_v1_t* protocol) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    free(protocol);
+
+    return status;
+}
+
+celix_status_t pubsubProtocol_getSyncHeader(void* handle, void *syncHeader) {
+    for (int i = 0; i < 5; ++i) {
+        ((char *) syncHeader)[i] = '\0';
+    }
+    writeInt(syncHeader, 0, PROTOCOL_WIRE_SYNC);
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t pubsubProtocol_encodeHeader(void *handle, pubsub_protocol_message_t *message, void **outBuffer, size_t *outLength) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    *outBuffer = calloc(1, 24);
+    if (*outBuffer == NULL) {
+        status = CELIX_ENOMEM;
+    } else {
+        int idx = 0;
+        idx = writeInt(*outBuffer, idx, PROTOCOL_WIRE_SYNC);
+        idx = writeInt(*outBuffer, idx, PROTOCOL_WIRE_ENVELOPE_VERSION);
+        idx = writeInt(*outBuffer, idx, message->header.msgId);
+        idx = writeShort(*outBuffer, idx, message->header.msgMajorVersion);
+        idx = writeShort(*outBuffer, idx, message->header.msgMinorVersion);
+        idx = writeInt(*outBuffer, idx, message->header.payloadSize);
+        idx = writeInt(*outBuffer, idx, message->header.metadataSize);
+
+        *outLength = idx;
+    }
+
+    return status;
+}
+
+celix_status_t pubsubProtocol_encodePayload(void *handle, pubsub_protocol_message_t *message, void **outBuffer, size_t *outLength) {
+    *outBuffer = message->payload.payload;
+    *outLength = message->payload.length;
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t pubsubProtocol_encodeMetadata(void *handle, pubsub_protocol_message_t *message, void **outBuffer, size_t *outLength) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    char *line = calloc(1, 4);
+    size_t idx = 4;
+    size_t len = 0;
+
+    const char *key;
+    if (message->metadata.metadata != NULL && celix_properties_size(message->metadata.metadata) > 0) {
+        CELIX_PROPERTIES_FOR_EACH(message->metadata.metadata, key) {
+            const char *val = celix_properties_get(message->metadata.metadata, key, "!Error!");
+            char *keyNetString = NULL;
+            char *valueNetString = NULL;
+
+            status = pubsubProtocol_createNetstring(key, &keyNetString);
+            if (status != CELIX_SUCCESS) {
+                break;
+            }
+            status = pubsubProtocol_createNetstring(val, &valueNetString);
+            if (status != CELIX_SUCCESS) {
+                break;
+            }
+
+            len += strlen(keyNetString);
+            len += strlen(valueNetString);
+            char *tmp = realloc(line, len + sizeof(uint32_t));
+            if (!tmp) {
+                free(line);
+                status = CELIX_ENOMEM;
+                return status;
+            }
+            line = tmp;
+
+            memcpy(line + idx, keyNetString, strlen(keyNetString));
+            idx += strlen(keyNetString);
+            memcpy(line + idx, valueNetString, strlen(keyNetString));
+            idx += strlen(valueNetString);
+
+            free(keyNetString);
+            free(valueNetString);
+        }
+    }
+    int size = celix_properties_size(message->metadata.metadata);
+    memcpy(line, &size, sizeof(int32_t));
+
+    *outBuffer = line;
+    *outLength = idx;
+
+    return status;
+}
+
+celix_status_t pubsubProtocol_decodeHeader(void* handle, void *data, size_t length, pubsub_protocol_message_t *message) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    int idx = 0;
+    unsigned int sync;
+    idx = readInt(data, idx, &sync);
+    if (sync != PROTOCOL_WIRE_SYNC) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    } else {
+        unsigned int envelopeVersion;
+        idx = readInt(data, idx, &envelopeVersion);
+        if (envelopeVersion != PROTOCOL_WIRE_ENVELOPE_VERSION) {
+            status = CELIX_ILLEGAL_ARGUMENT;
+        } else {
+            idx = readInt(data, idx, &message->header.msgId);
+            idx = readShort(data, idx, &message->header.msgMajorVersion);
+            idx = readShort(data, idx, &message->header.msgMinorVersion);
+            idx = readInt(data, idx, &message->header.payloadSize);
+            readInt(data, idx, &message->header.metadataSize);
+        }
+    }
+
+    return status;
+}
+
+celix_status_t pubsubProtocol_decodePayload(void* handle, void *data, size_t length, pubsub_protocol_message_t *message){
+    message->payload.payload = data;
+    message->payload.length = length;
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t pubsubProtocol_decodeMetadata(void* handle, void *data, size_t length, pubsub_protocol_message_t *message) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    uint32_t nOfElements;
+    size_t idx = readInt(data, 0, &nOfElements);
+    char *netstring = data + idx;
+    int netstringLen = length - idx;
+
+    message->metadata.metadata = celix_properties_create();
+    while (idx < length) {
+        size_t outlen;
+        status = pubsubProtocol_parseNetstring(netstring, netstringLen, &netstring, &outlen);
+        if (status != CELIX_SUCCESS) {
+            break;
+        }
+        char *key = strndup(netstring, outlen);
+        netstring += outlen + 1;
+        idx += outlen + 3;
+
+        status = pubsubProtocol_parseNetstring(netstring, netstringLen, &netstring, &outlen);
+        if (status != CELIX_SUCCESS) {
+            break;
+        }
+        char *value = strndup(netstring, outlen);
+        netstring += outlen + 1;
+        idx += outlen + 3;
+
+        celix_properties_setWithoutCopy(message->metadata.metadata, key, value);
+    }
+
+    return status;
+}
+
+static celix_status_t pubsubProtocol_createNetstring(const char* string, char** netstringOut) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    size_t str_len = strlen(string);
+    if (str_len == 0) {
+        // 0:,
+        *netstringOut = calloc(1, 4);
+        if (*netstringOut == NULL) {
+            status = CELIX_ENOMEM;
+        } else {
+            *netstringOut[0] = '0';
+            *netstringOut[1] = ':';
+            *netstringOut[2] = ',';
+            *netstringOut[3] = '\0';
+        }
+    } else {
+        size_t numlen = ceil(log10(str_len + 1));
+        *netstringOut = calloc(1, numlen + str_len + 3);
+        if (*netstringOut == NULL) {
+            status = CELIX_ENOMEM;
+        } else {
+            sprintf(*netstringOut, "%zu:%s,", str_len, string);
+        }
+    }
+
+    return status;
+}
+
+/* Reads a netstring from a `buffer` of length `buffer_length`. Writes
 
 Review comment:
   Code comes from https://github.com/PeterScott/netstring-c, which does not list a license, and only mentions "public domain". S0 not needed I think?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [celix] pnoltes commented on a change in pull request #156: Added protocol service API and wire protocol implementation to be use…

Posted by GitBox <gi...@apache.org>.
pnoltes commented on a change in pull request #156: Added protocol service API and wire protocol implementation to be use…
URL: https://github.com/apache/celix/pull/156#discussion_r388179559
 
 

 ##########
 File path: bundles/pubsub/pubsub_spi/include/pubsub_protocol.h
 ##########
 @@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef PUBSUB_PROTOCOL_SERVICE_H_
+#define PUBSUB_PROTOCOL_SERVICE_H_
+
+#include "celix_properties.h"
+
+#define PUBSUB_PROTOCOL_SERVICE_NAME      "pubsub_protocol"
+#define PUBSUB_PROTOCOL_SERVICE_VERSION   "1.0.0"
+#define PUBSUB_PROTOCOL_SERVICE_RANGE     "[1,2)"
+
+typedef struct pubsub_protocol_header pubsub_protocol_header_t;
+
+struct pubsub_protocol_header {
+    unsigned int msgId;
+    unsigned short msgMajorVersion;
+    unsigned short msgMinorVersion;
+
+    unsigned int payloadSize;
+    unsigned int metadataSize;
+};
+
+typedef struct pubsub_protocol_payload pubsub_protocol_payload_t;
+
+struct pubsub_protocol_payload {
+    void *payload;
+    size_t length;
+};
+
+typedef struct pubsub_protocol_metadata pubsub_protocol_metadata_t;
+
+struct pubsub_protocol_metadata {
+    celix_properties_t *metadata;
+};
+
+typedef struct pubsub_protocol_message pubsub_protocol_message_t;
+
+struct pubsub_protocol_message {
+    pubsub_protocol_header_t header;
+    pubsub_protocol_payload_t payload;
+    pubsub_protocol_metadata_t metadata;
+};
+
+typedef struct pubsub_protocol_service {
+    void* handle;
+
+    celix_status_t (*getSyncHeader)(void *handle, void *sync);
 
 Review comment:
   I know this missing for the rest of the SPI, but add some documentation for the service / functions.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [celix] abroekhuis merged pull request #156: Added protocol service API and wire protocol implementation to be use…

Posted by GitBox <gi...@apache.org>.
abroekhuis merged pull request #156: Added protocol service API and wire protocol implementation to be use…
URL: https://github.com/apache/celix/pull/156
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [celix] pnoltes commented on a change in pull request #156: Added protocol service API and wire protocol implementation to be use…

Posted by GitBox <gi...@apache.org>.
pnoltes commented on a change in pull request #156: Added protocol service API and wire protocol implementation to be use…
URL: https://github.com/apache/celix/pull/156#discussion_r388175963
 
 

 ##########
 File path: bundles/pubsub/examples/pubsub/subscriber/private/src/pubsub_subscriber.c
 ##########
 @@ -53,9 +55,19 @@ void subscriber_destroy(pubsub_receiver_t *subscriber) {
     free(subscriber);
 }
 
-int pubsub_subscriber_recv(void* handle, const char* msgType, unsigned int msgTypeId, void* msg, bool* release) {
+int pubsub_subscriber_recv(void* handle, const char* msgType, unsigned int msgTypeId, void* msg, const celix_properties_t *metadata, bool* release) {
     location_t place = (location_t)msg;
     printf("Recv (%s): [%f, %f] (%s, %s, %s, len data %li)\n", msgType, place->position.lat, place->position.lon, place->name, place->description, place->extra, (long)(strlen(place->data) + 1));
 
+    if (metadata == NULL || celix_properties_size(metadata) == 0) {
+        printf("No metadata\n");
 
 Review comment:
   remove printf

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [celix] pnoltes commented on a change in pull request #156: Added protocol service API and wire protocol implementation to be use…

Posted by GitBox <gi...@apache.org>.
pnoltes commented on a change in pull request #156: Added protocol service API and wire protocol implementation to be use…
URL: https://github.com/apache/celix/pull/156#discussion_r388175963
 
 

 ##########
 File path: bundles/pubsub/examples/pubsub/subscriber/private/src/pubsub_subscriber.c
 ##########
 @@ -53,9 +55,19 @@ void subscriber_destroy(pubsub_receiver_t *subscriber) {
     free(subscriber);
 }
 
-int pubsub_subscriber_recv(void* handle, const char* msgType, unsigned int msgTypeId, void* msg, bool* release) {
+int pubsub_subscriber_recv(void* handle, const char* msgType, unsigned int msgTypeId, void* msg, const celix_properties_t *metadata, bool* release) {
     location_t place = (location_t)msg;
     printf("Recv (%s): [%f, %f] (%s, %s, %s, len data %li)\n", msgType, place->position.lat, place->position.lon, place->name, place->description, place->extra, (long)(strlen(place->data) + 1));
 
+    if (metadata == NULL || celix_properties_size(metadata) == 0) {
+        printf("No metadata\n");
 
 Review comment:
   remove printf

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services