summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authoryangwei <[email protected]>2024-11-25 19:22:41 +0800
committeryangwei <[email protected]>2024-11-25 19:22:41 +0800
commite2776414401af0bc02beb305b0d366fe3828cffd (patch)
tree46aecfbe9531f15717626b2b4ec8d2a39e5603f2 /include
parent40083638202cbedea0728ce0ebe49472212aad9f (diff)
✨ feat(deps/utable): define kv in utable.h temporary
Diffstat (limited to 'include')
-rw-r--r--include/stellar/kv.h100
-rw-r--r--include/stellar/module.h19
2 files changed, 18 insertions, 101 deletions
diff --git a/include/stellar/kv.h b/include/stellar/kv.h
deleted file mode 100644
index 9f8bcc1..0000000
--- a/include/stellar/kv.h
+++ /dev/null
@@ -1,100 +0,0 @@
-#pragma once
-
-#include <stddef.h>
-#include <uuid/uuid.h>
-
-struct kv
-{
- char *key;
- size_t key_sz;
- enum
- {
- KV_VALUE_TYPE_INTEGER,
- KV_VALUE_TYPE_DOUBLE,
- KV_VALUE_TYPE_STRING,
- KV_VALUE_TYPE_UUID,
- KV_VALUE_TYPE_INTERGE_ARRAY,
- KV_VALUE_TYPE_DOUBLE_ARRAY,
- KV_VALUE_TYPE_STRING_ARRAY,
- KV_VALUE_TYPE_UUID_ARRAY
- }vtype;
- union
- {
- long long value_longlong;
- double value_double;
- struct
- {
- char *str;
- size_t sz;
- }value_str;
- uuid_t value_uuid;
- struct
- {
- long long *elems;
- size_t n_elems;
- }value_interger_array;
- struct
- {
- double *elems;
- size_t n_elems;
- }value_double_array;
- struct
- {
- char **elems;
- size_t *sz;
- size_t n_elems;
- }value_str_array;
- struct
- {
- uuid_t *elems;
- size_t n_elems;
- }value_uuid_array;
-/*
- struct
- {
- struct kv *elems;
- size_t n_elems;
- }value_list;
-*/
- };
-};
-
-struct kv *kv_new_with_interger(const char *key, size_t key_sz, long long value);
-struct kv *kv_new_with_double(const char *key, size_t key_sz, double value);
-struct kv *kv_new_with_string(const char *key, size_t key_sz, const char *value, size_t value_sz);
-struct kv *kv_new_with_uuid(const char *key, size_t key_sz, const uuid_t value);
-struct kv *kv_new_with_interger_array(const char *key, size_t key_sz, long long value[], size_t n_value);
-struct kv *kv_new_with_double_array(const char *key, size_t key_sz, double value[], size_t n_value);
-struct kv *kv_new_with_string_array(const char *key, size_t key_sz, const char* value[], size_t value_sz[], size_t n_value);
-struct kv *kv_new_with_uuid_array(const char *key, size_t key_sz, const uuid_t value[], size_t n_value);
-
-struct kv *kv_duplicate(const struct kv *kv);
-
-void kv_free(struct kv *kv);
-
-struct kv_table;
-
-struct kv_table *kv_table_new(size_t initial_size);
-void kv_table_free(struct kv_table *table);
-
-//struct kv_table *kv_table_new_by_indexing(struct kv *kv);
-
-int kv_table_add(struct kv_table *table, const struct kv *kv);
-int kv_table_del(struct kv_table *table, const char *key, size_t key_sz);
-
-typedef void (kv_ref_cleanup_cb)(const struct kv *kv, void *arg);
-int kv_table_add_reference(struct kv_table *table, const struct kv *kv, kv_ref_cleanup_cb *cleanup_cb, void *arg);
-
-const struct kv *kv_table_get0(struct kv_table *table, const char *key, size_t key_sz);
-
-void kv_table_reset_iter(struct kv_table *table);
-const struct kv *kv_table_next(struct kv_table *table);
-
-struct kv_table *kv_table_duplicate(const struct kv_table *table);
-int kv_table_union(struct kv_table *dst, const struct kv_table *src);
-
-void kv_table_serialize(const struct kv_table *table, char **blob, size_t *blob_len);
-struct kv_table *kv_table_deserialize(const char *blob, size_t blob_len);
-
-int kv_table_export_json(const struct kv_table *table, char **blob, size_t *blob_len);
-int kv_table_export_msgpack(const struct kv_table *table, char **blob, size_t *blob_len); \ No newline at end of file
diff --git a/include/stellar/module.h b/include/stellar/module.h
index bc96b46..b0dc738 100644
--- a/include/stellar/module.h
+++ b/include/stellar/module.h
@@ -1,5 +1,6 @@
#pragma once
+#include <stdlib.h>
#ifdef __cplusplus
extern "C"
{
@@ -8,6 +9,10 @@ extern "C"
#include "stellar/mq.h"
#include "stellar/log.h"
+/*******************************************
+ * module API *
+ *******************************************/
+
struct module;
struct module *module_new(const char *name, void *ctx);
void module_free(struct module *mod);
@@ -18,6 +23,10 @@ void module_set_ctx(struct module *mod, void *ctx);
const char *module_get_name(struct module* mod);
void module_set_name(struct module* mod, const char *name);
+/*******************************************
+ * module API *
+ *******************************************/
+
struct module_manager;
typedef struct module *module_on_instance_init_func(struct module_manager *mod_mgr);
@@ -26,7 +35,15 @@ typedef void module_on_instance_exit_func(struct module_manager *mod_mgr, struct
typedef struct module *module_on_thread_init_func(struct module_manager *mod_mgr, int thread_id, struct module *mod);
typedef void module_on_thread_exit_func(struct module_manager *mod_mgr, int thread_id, struct module *mod);
-struct module_manager *module_manager_new(const char *module_spec_toml_path, int max_thread_num, struct mq_schema *mq_schema, struct logger *logger);
+struct module_specification
+{
+ module_on_instance_init_func *on_instance_init_cb;
+ module_on_instance_exit_func *on_instance_exit_cb;
+ module_on_thread_init_func *on_thread_init_cb;
+ module_on_thread_exit_func *on_thread_exit_cb;
+};
+
+struct module_manager *module_manager_new(struct module_specification mod_specs[], size_t n_mod, int max_thread_num, struct mq_schema *mq_schema, struct logger *logger);
void module_manager_free(struct module_manager *mod_mgr);
void module_manager_register_thread(struct module_manager *mod_mgr, int thread_id, struct mq_runtime *mq_rt);