Skip to content

Commit 28edf76

Browse files
out_azure_blob: fix compilation if FLB_SQLDB (sqlite3) is disabled
Signed-off-by: Thomas Devoogdt <[email protected]>
1 parent 3317b17 commit 28edf76

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

plugins/out_azure_blob/azure_blob.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <fluent-bit/flb_config_map.h>
2626
#include <fluent-bit/flb_gzip.h>
2727
#include <fluent-bit/flb_base64.h>
28-
#include <fluent-bit/flb_sqldb.h>
2928
#include <fluent-bit/flb_input_blob.h>
3029
#include <fluent-bit/flb_log_event_decoder.h>
3130
#include <fluent-bit/flb_plugin.h>
@@ -35,14 +34,17 @@
3534
#include <msgpack.h>
3635

3736
#include "azure_blob.h"
38-
#include "azure_blob_db.h"
3937
#include "azure_blob_uri.h"
4038
#include "azure_blob_conf.h"
4139
#include "azure_blob_appendblob.h"
4240
#include "azure_blob_blockblob.h"
4341
#include "azure_blob_http.h"
4442
#include "azure_blob_store.h"
4543

44+
#ifdef FLB_HAVE_SQLDB
45+
#include "azure_blob_db.h"
46+
#endif
47+
4648
#define CREATE_BLOB 1337
4749

4850
/* thread_local_storage for workers */
@@ -248,6 +250,7 @@ static int create_blob(struct flb_azure_blob *ctx, char *name)
248250
return FLB_OK;
249251
}
250252

253+
#ifdef FLB_HAVE_SQLDB
251254
static int delete_blob(struct flb_azure_blob *ctx, char *name)
252255
{
253256
int ret;
@@ -322,6 +325,7 @@ static int delete_blob(struct flb_azure_blob *ctx, char *name)
322325
flb_upstream_conn_release(u_conn);
323326
return FLB_OK;
324327
}
328+
#endif
325329

326330
static int http_send_blob(struct flb_config *config, struct flb_azure_blob *ctx,
327331
flb_sds_t ref_name,
@@ -488,16 +492,23 @@ static int send_blob(struct flb_config *config,
488492
if (!block_id) {
489493
flb_plg_error(ctx->ins, "could not generate block id");
490494
flb_free(generated_random_string);
491-
cfl_sds_destroy(ref_name);
495+
flb_sds_destroy(ref_name);
492496
return FLB_RETRY;
493497
}
494498
uri = azb_block_blob_uri(ctx, tag, block_id, ms, generated_random_string);
495499
ref_name = flb_sds_printf(&ref_name, "file=%s.%" PRIu64, name, ms);
496500
}
497501
else if (event_type == FLB_EVENT_TYPE_BLOBS) {
502+
#ifdef FLB_HAVE_SQLDB
498503
block_id = azb_block_blob_id_blob(ctx, name, part_id);
499504
uri = azb_block_blob_uri(ctx, name, block_id, 0, generated_random_string);
500505
ref_name = flb_sds_printf(&ref_name, "file=%s:%" PRIu64, name, part_id);
506+
#else
507+
flb_plg_error(ctx->ins, "FLB_EVENT_TYPE_BLOBS requires FLB_HAVE_SQLDB enabled at build time");
508+
flb_free(generated_random_string);
509+
flb_sds_destroy(ref_name);
510+
return FLB_ERROR;
511+
#endif
501512
}
502513
}
503514

@@ -772,6 +783,7 @@ static int cb_azure_blob_init(struct flb_output_instance *ins,
772783
return 0;
773784
}
774785

786+
#ifdef FLB_HAVE_SQLDB
775787
static int blob_chunk_register_parts(struct flb_azure_blob *ctx, uint64_t file_id, size_t total_size)
776788
{
777789
int ret;
@@ -1171,6 +1183,7 @@ static int azb_timer_create(struct flb_azure_blob *ctx)
11711183

11721184
return 0;
11731185
}
1186+
#endif
11741187

11751188
/**
11761189
* Azure Blob Storage ingestion callback function
@@ -1660,6 +1673,7 @@ static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk,
16601673
}
16611674
}
16621675
else if (event_chunk->type == FLB_EVENT_TYPE_BLOBS) {
1676+
#ifdef FLB_HAVE_SQLDB
16631677
/*
16641678
* For Blob types, we use the flush callback to enqueue the file, then cb_azb_blob_file_upload()
16651679
* takes care of the rest like reading the file and uploading it to Azure.
@@ -1668,6 +1682,9 @@ static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk,
16681682
if (ret == -1) {
16691683
FLB_OUTPUT_RETURN(FLB_RETRY);
16701684
}
1685+
#else
1686+
ret = FLB_ERROR;
1687+
#endif
16711688
}
16721689

16731690
if (json){
@@ -1728,11 +1745,13 @@ static int cb_worker_init(void *data, struct flb_config *config)
17281745
FLB_TLS_SET(worker_info, info);
17291746
}
17301747

1748+
#ifdef FLB_HAVE_SQLDB
17311749
ret = azb_timer_create(ctx);
17321750
if (ret == -1) {
17331751
flb_plg_error(ctx->ins, "failed to create upload timer");
17341752
return -1;
17351753
}
1754+
#endif
17361755

17371756
return 0;
17381757
}

plugins/out_azure_blob/azure_blob.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
#include <fluent-bit/flb_output_plugin.h>
2424
#include <fluent-bit/flb_upstream.h>
2525
#include <fluent-bit/flb_sds.h>
26+
27+
#ifdef FLB_HAVE_SQLDB
2628
#include <fluent-bit/flb_sqldb.h>
29+
#endif
2730

2831
/* Content-Type */
2932
#define AZURE_BLOB_CT "Content-Type"

plugins/out_azure_blob/azure_blob_blockblob.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <fluent-bit/flb_time.h>
2323
#include <fluent-bit/flb_sds.h>
2424
#include <fluent-bit/flb_hash.h>
25+
#include <fluent-bit/flb_utils.h>
2526
#include <fluent-bit/flb_crypto_constants.h>
2627

2728
#include <math.h>

plugins/out_azure_blob/azure_blob_conf.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@
2020
#include <fluent-bit/flb_output_plugin.h>
2121
#include <fluent-bit/flb_base64.h>
2222
#include <fluent-bit/flb_pack.h>
23+
#include <fluent-bit/flb_utils.h>
2324

2425
#include "azure_blob.h"
2526
#include "azure_blob_conf.h"
27+
28+
#ifdef FLB_HAVE_SQLDB
2629
#include "azure_blob_db.h"
30+
#endif
2731

2832
#include <sys/types.h>
2933
#include <sys/stat.h>
@@ -762,6 +766,7 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in
762766
}
763767
}
764768

769+
#ifdef FLB_HAVE_SQLDB
765770
/* database file for blob signal handling */
766771
if (ctx->database_file) {
767772
ctx->db = azb_db_open(ctx, ctx->database_file);
@@ -771,6 +776,7 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in
771776
}
772777

773778
pthread_mutex_init(&ctx->file_upload_commit_file_parts, NULL);
779+
#endif
774780

775781
flb_plg_info(ctx->ins,
776782
"account_name=%s, container_name=%s, blob_type=%s, emulator_mode=%s, endpoint=%s, auth_type=%s",
@@ -826,7 +832,9 @@ void flb_azure_blob_conf_destroy(struct flb_azure_blob *ctx)
826832
flb_upstream_destroy(ctx->u);
827833
}
828834

829-
835+
#ifdef FLB_HAVE_SQLDB
830836
azb_db_close(ctx);
837+
#endif
838+
831839
flb_free(ctx);
832840
}

0 commit comments

Comments
 (0)