EII Message Bus C Reference
msgbus.h
Go to the documentation of this file.
1 // Copyright (c) 2019 Intel Corporation.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 // FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 // IN THE SOFTWARE.
20 
27 #ifndef _EII_MESSAGE_BUS_H
28 #define _EII_MESSAGE_BUS_H
29 
30 #include <stdbool.h>
31 #include <stdint.h>
32 #include <time.h>
33 #include <eii/utils/config.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
43 typedef struct {
44  void* data;
45  void (*free)(void* data);
46 } user_data_t;
47 
52 typedef struct {
53  void* ctx;
54  user_data_t* user_data;
55 } recv_ctx_t;
56 
60 typedef struct {
61  int size;
62  int max_size;
63  bool* tbl_ready;
64  recv_ctx_t** tbl_ctxs;
66 
70 typedef void* publisher_ctx_t;
71 
81 void* msgbus_initialize(config_t* config);
82 
86 void msgbus_destroy(void* ctx);
87 
103  void* ctx, const char* topic, publisher_ctx_t** pub_ctx);
104 
114  void* ctx, publisher_ctx_t* pub_ctx, msg_envelope_t* message);
115 
122 void msgbus_publisher_destroy(void* ctx, publisher_ctx_t* pub_ctx);
123 
137  void* ctx, const char* topic, user_data_t* user_data,
138  recv_ctx_t** subscriber);
139 
146 void msgbus_recv_ctx_destroy(void* ctx, recv_ctx_t* recv_ctx);
147 
157  void* ctx, recv_ctx_t* service_ctx, msg_envelope_t* message);
158 
168  void* ctx, recv_ctx_t* service_ctx, msg_envelope_t* message);
169 
183  void* ctx, const char* service_name, void* user_data,
184  recv_ctx_t** service_ctx);
185 
199  void* ctx, const char* service_name, void* user_data,
200  recv_ctx_t** service_ctx);
201 
214  void* ctx, recv_ctx_t* recv_ctx, msg_envelope_t** message);
215 
228  void* ctx, recv_ctx_t* recv_ctx, int timeout,
229  msg_envelope_t** message);
230 
241  void* ctx, recv_ctx_t* recv_ctx, msg_envelope_t** message);
242 
243 #ifdef __cplusplus
244 } // extern "C"
245 #endif // __cpluspplus
246 
247 #endif // _EII_MESSAGE_BUS_H
msgbus_recv_nowait
msgbus_ret_t msgbus_recv_nowait(void *ctx, recv_ctx_t *recv_ctx, msg_envelope_t **message)
user_data_t
Definition: msgbus.h:43
msg_envelope.h
Messaging envelope abstraction.
msgbus_recv_timedwait
msgbus_ret_t msgbus_recv_timedwait(void *ctx, recv_ctx_t *recv_ctx, int timeout, msg_envelope_t **message)
msgbus_publisher_new
msgbus_ret_t msgbus_publisher_new(void *ctx, const char *topic, publisher_ctx_t **pub_ctx)
msgbus_publisher_destroy
void msgbus_publisher_destroy(void *ctx, publisher_ctx_t *pub_ctx)
msgbus_recv_wait
msgbus_ret_t msgbus_recv_wait(void *ctx, recv_ctx_t *recv_ctx, msg_envelope_t **message)
msgbus_ret_t
msgbus_ret_t
Definition: msgbusret.h:36
msg_envelope_t
Definition: msg_envelope.h:111
publisher_ctx_t
void * publisher_ctx_t
Definition: msgbus.h:70
msgbus_request
msgbus_ret_t msgbus_request(void *ctx, recv_ctx_t *service_ctx, msg_envelope_t *message)
msgbus_publisher_publish
msgbus_ret_t msgbus_publisher_publish(void *ctx, publisher_ctx_t *pub_ctx, msg_envelope_t *message)
recv_ctx_set_t
Definition: msgbus.h:60
msgbus_subscriber_new
msgbus_ret_t msgbus_subscriber_new(void *ctx, const char *topic, user_data_t *user_data, recv_ctx_t **subscriber)
msgbus_response
msgbus_ret_t msgbus_response(void *ctx, recv_ctx_t *service_ctx, msg_envelope_t *message)
msgbus_service_get
msgbus_ret_t msgbus_service_get(void *ctx, const char *service_name, void *user_data, recv_ctx_t **service_ctx)
msgbus_initialize
void * msgbus_initialize(config_t *config)
msgbus_service_new
msgbus_ret_t msgbus_service_new(void *ctx, const char *service_name, void *user_data, recv_ctx_t **service_ctx)
recv_ctx_t
Definition: msgbus.h:52
msgbus_recv_ctx_destroy
void msgbus_recv_ctx_destroy(void *ctx, recv_ctx_t *recv_ctx)
msgbus_destroy
void msgbus_destroy(void *ctx)