Skip to content

Commit

Permalink
lib/core: Add configuration for maximum inject size (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
JBenda authored and michaelkuhn committed Jan 30, 2022
1 parent 431cd6d commit 9194ca8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/core/jconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ gchar const* j_configuration_get_backend_component(JConfiguration*, JBackendType
gchar const* j_configuration_get_backend_path(JConfiguration*, JBackendType);

guint64 j_configuration_get_max_operation_size(JConfiguration*);
guint64 j_configuration_get_max_inject_size(JConfiguration*);
guint16 j_configuration_get_port(JConfiguration*);

guint32 j_configuration_get_max_connections(JConfiguration*);
Expand Down
19 changes: 19 additions & 0 deletions lib/core/jconfiguration.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ struct JConfiguration
} db;

guint64 max_operation_size;
guint64 max_inject_size;
guint16 port;

guint32 max_connections;
Expand Down Expand Up @@ -282,13 +283,15 @@ j_configuration_new_for_data(GKeyFile* key_file)
gchar* db_component;
gchar* db_path;
guint64 max_operation_size;
guint64 max_inject_size;
guint32 port;
guint32 max_connections;
guint64 stripe_size;

g_return_val_if_fail(key_file != NULL, FALSE);

max_operation_size = g_key_file_get_uint64(key_file, "core", "max-operation-size", NULL);
max_inject_size = g_key_file_get_uint64(key_file, "core", "max-inject-size", NULL);
port = g_key_file_get_integer(key_file, "core", "port", NULL);
max_connections = g_key_file_get_integer(key_file, "clients", "max-connections", NULL);
stripe_size = g_key_file_get_uint64(key_file, "clients", "stripe-size", NULL);
Expand Down Expand Up @@ -355,6 +358,7 @@ j_configuration_new_for_data(GKeyFile* key_file)
configuration->db.path = db_path;
configuration->max_operation_size = max_operation_size;
configuration->port = port;
configuration->max_inject_size = max_inject_size;
configuration->max_connections = max_connections;
configuration->stripe_size = stripe_size;
configuration->ref_count = 1;
Expand All @@ -364,6 +368,11 @@ j_configuration_new_for_data(GKeyFile* key_file)
configuration->max_operation_size = 8 * 1024 * 1024;
}

if (configuration->max_inject_size == 0)
{
configuration->max_inject_size = configuration->max_operation_size / 1024;
}

if (configuration->port == 0)
{
g_autoptr(JCredentials) credentials = j_credentials_new();
Expand Down Expand Up @@ -548,6 +557,16 @@ j_configuration_get_max_operation_size(JConfiguration* configuration)
return configuration->max_operation_size;
}

guint64
j_configuration_get_max_inject_size(JConfiguration* configuration)
{
J_TRACE_FUNCTION(NULL);

g_return_val_if_fail(configuration != NULL, 0);

return configuration->max_inject_size;
}

guint32
j_configuration_get_max_connections(JConfiguration* configuration)
{
Expand Down

0 comments on commit 9194ca8

Please sign in to comment.