include shard domain and remote users in taler config

This commit is contained in:
Marco Boss 2022-05-02 00:27:59 +02:00
parent a4ede7caec
commit 72ae759fa0
No known key found for this signature in database
GPG Key ID: 89A3EC33C625C3DF
2 changed files with 65 additions and 9 deletions

View File

@ -2627,7 +2627,9 @@ COMMENT ON FUNCTION create_shard_server
CREATE OR REPLACE FUNCTION create_foreign_servers( CREATE OR REPLACE FUNCTION create_foreign_servers(
amount INTEGER amount INTEGER
,domain VARCHAR DEFAULT 'perf.taler' ,domain VARCHAR
,remote_user VARCHAR DEFAULT 'taler'
,remote_user_password VARCHAR DEFAULT 'taler'
) )
RETURNS VOID RETURNS VOID
LANGUAGE plpgsql LANGUAGE plpgsql
@ -2642,14 +2644,16 @@ BEGIN
,amount ,amount
,i ,i
,'shard-' || i::varchar || '.' || domain ,'shard-' || i::varchar || '.' || domain
,'taler' ,remote_user
,'taler' ,remote_user_password
,'taler-exchange' ,'taler-exchange'
,'5432' ,'5432'
,'taler-exchange-httpd' ,'taler-exchange-httpd'
); );
END LOOP; END LOOP;
PERFORM drop_default_partitions();
END END
$$; $$;

View File

@ -356,16 +356,61 @@ postgres_setup_foreign_servers (void *cls,
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
struct GNUNET_PQ_Context *conn; struct GNUNET_PQ_Context *conn;
enum GNUNET_GenericReturnValue ret = GNUNET_OK; enum GNUNET_GenericReturnValue ret = GNUNET_OK;
char *shard_domain = NULL;
char *remote_user = NULL;
char *remote_user_pw = NULL;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (pg->cfg,
"exchange",
"SHARD_DOMAIN",
&shard_domain))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"SHARD_DOMAIN");
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (pg->cfg,
"exchangedb-postgres",
"SHARD_REMOTE_USER",
&remote_user))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchangedb-postgres",
"SHARD_REMOTE_USER");
GNUNET_free (shard_domain);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (pg->cfg,
"exchangedb-postgres",
"SHARD_REMOTE_USER_PW",
&remote_user_pw))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchangedb-postgres",
"SHARD_REMOTE_USER_PW");
GNUNET_free (shard_domain);
GNUNET_free (remote_user);
return GNUNET_SYSERR;
}
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint32 (&num), GNUNET_PQ_query_param_uint32 (&num),
GNUNET_PQ_query_param_string (shard_domain),
GNUNET_PQ_query_param_string (remote_user),
GNUNET_PQ_query_param_string (remote_user_pw),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
struct GNUNET_PQ_PreparedStatement ps[] = { struct GNUNET_PQ_PreparedStatement ps[] = {
GNUNET_PQ_make_prepare ("create_foreign_servers", GNUNET_PQ_make_prepare ("create_foreign_servers",
"SELECT" "SELECT"
" create_foreign_servers" " create_foreign_servers"
" ($1);", " ($1, $2, $3, $4);",
1), 4),
GNUNET_PQ_PREPARED_STATEMENT_END GNUNET_PQ_PREPARED_STATEMENT_END
}; };
@ -375,11 +420,18 @@ postgres_setup_foreign_servers (void *cls,
NULL, NULL,
ps); ps);
if (NULL == conn) if (NULL == conn)
return GNUNET_SYSERR; {
if (0 > GNUNET_PQ_eval_prepared_non_select (conn, ret = GNUNET_SYSERR;
}
else if (0 > GNUNET_PQ_eval_prepared_non_select (conn,
"create_foreign_servers", "create_foreign_servers",
params)) params))
{
ret = GNUNET_SYSERR; ret = GNUNET_SYSERR;
}
GNUNET_free (shard_domain);
GNUNET_free (remote_user);
GNUNET_free (remote_user_pw);
GNUNET_PQ_disconnect (conn); GNUNET_PQ_disconnect (conn);
return ret; return ret;
} }