Skip to content

Commit

Permalink
Minor tweaks to try to decouple dyad_ctx from dyad_client
Browse files Browse the repository at this point in the history
  • Loading branch information
ilumsden committed Sep 3, 2024
1 parent 7aa6650 commit 989fc09
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 38 deletions.
1 change: 0 additions & 1 deletion include/dyad/client/dyad_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ extern "C" {
#else
#define DYAD_CORE_FUNC_MODS static inline
#endif
DYAD_DLL_EXPORTED extern const struct dyad_ctx dyad_ctx_default;

struct dyad_metadata {
char *fpath;
Expand Down
64 changes: 28 additions & 36 deletions include/dyad/core/dyad_ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
#error "no config"
#endif

#include <dyad/common/dyad_rc.h>
#include <dyad/common/dyad_dtl.h>
#include <dyad/common/dyad_rc.h>
#include <dyad/common/dyad_structures.h>

#ifdef __cplusplus
extern "C" {
#endif

DYAD_DLL_EXPORTED dyad_ctx_t* dyad_ctx_get ();
DYAD_DLL_EXPORTED void dyad_ctx_init (dyad_dtl_comm_mode_t dtl_comm_mode,
void* flux_handle);
DYAD_DLL_EXPORTED void dyad_ctx_fini ();
DYAD_DLL_EXPORTED extern const struct dyad_ctx dyad_ctx_default;

DYAD_DLL_EXPORTED dyad_ctx_t *dyad_ctx_get();
DYAD_DLL_EXPORTED void dyad_ctx_init(dyad_dtl_comm_mode_t dtl_comm_mode,
void *flux_handle);
DYAD_DLL_EXPORTED void dyad_ctx_fini();

/**
* @brief Intialize the DYAD context
Expand All @@ -34,58 +36,48 @@ DYAD_DLL_EXPORTED void dyad_ctx_fini ();
* @param[in] service_mux number of brokers sharing node-local storage
* @param[in] kvs_namespace Flux KVS namespace to be used for this
* instance of DYAD
* @param[in] relative_to_managed_path relative path is relative to the managed path
* Which one of the managed path it will be relative to
* depends on the context and it could be either of
* producer or consumer's path. This is only applicable
* when there is only one of each.
* @param[in] relative_to_managed_path relative path is relative to the managed
* path Which one of the managed path it will be relative to depends on the
* context and it could be either of producer or consumer's path. This is only
* applicable when there is only one of each.
* @param[in] dtl_mode_str DTL mode
* @param[in] dtl_comm_mode DTL comm mode
* @param[in] flux_handle Flux handle (flux_t*). If NULL, it will be obtained via
* `flux_open()`
* @param[in] flux_handle Flux handle (flux_t*). If NULL, it will be
* obtained via `flux_open()`
*
* @return An error code from dyad_rc.h
*/
DYAD_DLL_EXPORTED dyad_rc_t dyad_init (bool debug,
bool check,
bool shared_storage,
bool reinit,
bool async_publish,
bool fsync_write,
unsigned int key_depth,
unsigned int key_bins,
unsigned int service_mux,
const char* kvs_namespace,
const char* prod_managed_path,
const char* cons_managed_path,
bool relative_to_managed_path,
const char* dtl_mode_str,
const dyad_dtl_comm_mode_t dtl_comm_mode,
void* flux_handle);
DYAD_DLL_EXPORTED dyad_rc_t dyad_init(
bool debug, bool check, bool shared_storage, bool reinit,
bool async_publish, bool fsync_write, unsigned int key_depth,
unsigned int key_bins, unsigned int service_mux, const char *kvs_namespace,
const char *prod_managed_path, const char *cons_managed_path,
bool relative_to_managed_path, const char *dtl_mode_str,
const dyad_dtl_comm_mode_t dtl_comm_mode, void *flux_handle);

/**
* @brief Intialize the DYAD context using environment variables
*
* @return An error code from dyad_rc.h
*/
DYAD_DLL_EXPORTED dyad_rc_t dyad_init_env (const dyad_dtl_comm_mode_t dtl_comm_mode,
void* flux_handle);
DYAD_DLL_EXPORTED dyad_rc_t
dyad_init_env(const dyad_dtl_comm_mode_t dtl_comm_mode, void *flux_handle);

/**
* @brief Reset producer path. Can be used by the module
* @param[in] producer path string
*
* @return An error code from dyad_rc.h
*/
DYAD_DLL_EXPORTED dyad_rc_t dyad_set_prod_path (const char* path);
DYAD_DLL_EXPORTED dyad_rc_t dyad_set_prod_path(const char *path);

/**
* @brief Reset consumer path. Can be used by the module
* @param[in] consumer path string
*
* @return An error code from dyad_rc.h
*/
DYAD_DLL_EXPORTED dyad_rc_t dyad_set_cons_path (const char* path);
DYAD_DLL_EXPORTED dyad_rc_t dyad_set_cons_path(const char *path);

/**
* @brief Reset dtl mode. Can be used by the module
Expand All @@ -94,23 +86,23 @@ DYAD_DLL_EXPORTED dyad_rc_t dyad_set_cons_path (const char* path);
*
* @return An error code from dyad_rc.h
*/
DYAD_DLL_EXPORTED dyad_rc_t dyad_set_and_init_dtl_mode (const char* dtl_mode_name,
dyad_dtl_comm_mode_t dtl_comm_mode);
DYAD_DLL_EXPORTED dyad_rc_t dyad_set_and_init_dtl_mode(
const char *dtl_mode_name, dyad_dtl_comm_mode_t dtl_comm_mode);

/**
* Reset the contents of the ctx to the default values and deallocate
* internal objects linked. However, do not destroy the ctx object itself.
* This is needed for wrapper to handle dyad exceptions as the wrapper requires
* ctx for it's lifetime
*/
DYAD_DLL_EXPORTED dyad_rc_t dyad_clear ();
DYAD_DLL_EXPORTED dyad_rc_t dyad_clear();

/**
* @brief Finalizes the DYAD instance and deallocates the context
*
* @return An error code from dyad_rc.h
*/
DYAD_DLL_EXPORTED dyad_rc_t dyad_finalize ();
DYAD_DLL_EXPORTED dyad_rc_t dyad_finalize();

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion src/dyad/core/dyad_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <dyad/common/dyad_envs.h>
#include <dyad/common/dyad_logging.h>
#include <dyad/common/dyad_profiler.h>
#include <dyad/core/dyad_core_int.h>
// #include <dyad/core/dyad_core_int.h>
#include <dyad/core/dyad_ctx.h>
#include <dyad/dtl/dyad_dtl_api.h>
#include <dyad/utils/utils.h>
Expand Down

0 comments on commit 989fc09

Please sign in to comment.