diff options
author | Thomas White <taw@physics.org> | 2022-06-22 14:48:40 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2022-06-22 15:26:10 +0200 |
commit | aaf02b5fe6bec4745e0e88cf345e420715867b2e (patch) | |
tree | fc81995fce18d16ee41dc868bf1f8827a31fb389 /src/im-asapo.c | |
parent | 60df21975c5cbac190bf1e7b4d2e6627f1685dcf (diff) |
indexamajig: Wrap ASAP::O parameters up inside separate structure
Diffstat (limited to 'src/im-asapo.c')
-rw-r--r-- | src/im-asapo.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/im-asapo.c b/src/im-asapo.c index 2685036b..b19c5bdc 100644 --- a/src/im-asapo.c +++ b/src/im-asapo.c @@ -62,34 +62,29 @@ static void show_asapo_error(const char *msg, const AsapoErrorHandle err) } -struct im_asapo *im_asapo_connect(const char *endpoint, - const char *token, - const char *beamtime, - const char *group_id, - const char *data_source, - const char *stream) +struct im_asapo *im_asapo_connect(struct im_asapo_params *params) { struct im_asapo *a; AsapoSourceCredentialsHandle cred; AsapoErrorHandle err = asapo_new_handle(); - if ( endpoint == NULL ) { + if ( params->endpoint == NULL ) { ERROR("ASAP::O endpoint not specified.\n"); return NULL; } - if ( beamtime == NULL ) { + if ( params->beamtime == NULL ) { ERROR("ASAP::O beamtime not specified.\n"); return NULL; } - if ( group_id == NULL ) { + if ( params->group_id == NULL ) { ERROR("ASAP::O consumer group ID not specified.\n"); return NULL; } - if ( data_source == NULL ) { + if ( params->source == NULL ) { ERROR("ASAP::O data source not specified.\n"); return NULL; } - if ( stream == NULL ) { + if ( params->stream == NULL ) { ERROR("ASAP::O stream not specified.\n"); return NULL; } @@ -100,11 +95,11 @@ struct im_asapo *im_asapo_connect(const char *endpoint, cred = asapo_create_source_credentials(kProcessed, "auto", /* instance ID */ "indexamajig", /* pipeline step */ - beamtime, + params->beamtime, "", /* beamline */ - data_source, - token); - a->consumer = asapo_create_consumer(endpoint, "auto", 0, cred, &err); + params->source, + params->token); + a->consumer = asapo_create_consumer(params->endpoint, "auto", 0, cred, &err); asapo_free_handle(&cred); if ( asapo_is_error(err) ) { show_asapo_error("Cannot create ASAP::O consumer", err); @@ -112,9 +107,9 @@ struct im_asapo *im_asapo_connect(const char *endpoint, return NULL; } - a->stream = strdup(stream); + a->stream = strdup(params->stream); asapo_consumer_set_timeout(a->consumer, 3000); - a->group_id = asapo_string_from_c_str(group_id); + a->group_id = asapo_string_from_c_str(params->group_id); return a; } |