celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [celix] pnoltes commented on a change in pull request #223: Feature/pubsub custom serializers
Date Mon, 18 May 2020 07:12:46 GMT

pnoltes commented on a change in pull request #223:
URL: https://github.com/apache/celix/pull/223#discussion_r426411883



##########
File path: bundles/pubsub/pubsub_utils/src/pubsub_serialization_provider.c
##########
@@ -0,0 +1,668 @@
+/**
+ *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 "pubsub_serialization_provider.h"
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <dirent.h>
+#include <string.h>
+
+#include "celix_constants.h"
+#include "dyn_function.h"
+#include "celix_version.h"
+#include "celix_utils.h"
+#include "dyn_message.h"
+#include "pubsub_utils.h"
+#include "celix_log_helper.h"
+#include "pubsub_message_serialization_service.h"
+#include "celix_shell_command.h"
+
+#define MAX_PATH_LEN    1024
+
+typedef enum
+{
+    FIT_INVALID = 0,
+    FIT_DESCRIPTOR = 1,
+    FIT_AVPR = 2
+} descriptor_type_e;
+
+#define L_DEBUG(...) \
+    celix_logHelper_debug(provider->logHelper, __VA_ARGS__)
+#define L_INFO(...) \
+    celix_logHelper_info(provider->logHelper, __VA_ARGS__)
+#define L_WARN(...) \
+    celix_logHelper_warning(provider->logHelper, __VA_ARGS__)
+#define L_ERROR(...) \
+    celix_logHelper_error(provider->logHelper, __VA_ARGS__)
+
+
+struct pubsub_serialization_provider {
+    celix_bundle_context_t *ctx;
+    celix_log_helper_t *logHelper;
+    char* serializationType;
+
+    //serialization callbacks
+    celix_status_t (*serialize)(pubsub_serialization_entry_t* entry, const void* msg, struct
iovec** output, size_t* outputIovLen);
+    void (*freeSerializeMsg)(pubsub_serialization_entry_t* entry, struct iovec* input, size_t
inputIovLen);
+    celix_status_t (*deserialize)(pubsub_serialization_entry_t* entry, const struct iovec*
input, size_t inputIovLen __attribute__((unused)), void **out);
+    void (*freeDeserializeMsg)(pubsub_serialization_entry_t* entry, void *msg);
+
+    //updated serialization services
+    long bundleTrackerId;
+
+    pubsub_message_serialization_marker_t markerSvc;
+    long serializationMarkerSvcId;
+
+    celix_shell_command_t cmdSvc;
+    long cmdSvcId;
+
+    celix_thread_mutex_t mutex; //protects below
+    celix_array_list_t *serializationSvcEntries; //key = pubsub_serialization_entry;
+};
+
+static void dfi_log(void *handle, int level, const char *file, int line, const char *msg,
...) {
+    (void)level;
+    va_list ap;
+    pubsub_serialization_provider_t *provider = handle;
+    char *logStr = NULL;
+    va_start(ap, msg);
+    vasprintf(&logStr, msg, ap);
+    va_end(ap);
+    celix_logHelper_log(provider->logHelper, CELIX_LOG_LEVEL_WARNING, "FILE:%s, LINE:%i,
MSG:%s", file, line, logStr);
+    free(logStr);
+}
+
+static descriptor_type_e getDescriptorType(const char* filename) {
+    if (strstr(filename, ".descriptor")) {
+        return FIT_DESCRIPTOR;
+    }
+    else if (strstr(filename, ".properties")) {
+        return FIT_AVPR;
+    }
+    else {
+        return FIT_INVALID;
+    }
+}
+
+static bool readPropertiesFile(pubsub_serialization_provider_t* provider, const char* properties_file_name,
const char* root, char* avpr_fqn, char* path) {

Review comment:
       renamed




----------------------------------------------------------------
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



Mime
View raw message