Skip to content

Commit 8cf7987

Browse files
out_azure_blob: fix compilation if FLB_SQLDB (sqlite3) is disabled
Signed-off-by: Thomas Devoogdt <[email protected]>
1 parent 661acc9 commit 8cf7987

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

include/fluent-bit/flb_event.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
#define FLB_EVENT_TYPE_METRICS FLB_INPUT_CHUNK_TYPE_METRICS
3030
#define FLB_EVENT_TYPE_TRACES FLB_INPUT_CHUNK_TYPE_TRACES
3131
#define FLB_EVENT_TYPE_PROFILES FLB_INPUT_CHUNK_TYPE_PROFILES
32+
33+
#ifdef FLB_HAVE_SQLDB
3234
#define FLB_EVENT_TYPE_BLOBS FLB_INPUT_CHUNK_TYPE_BLOBS
35+
#endif
3336

3437
#define FLB_EVENT_TYPE_HAS_TRACE FLB_INPUT_CHUNK_HAS_TRACE
3538

plugins/out_azure_blob/azure_blob.c

Lines changed: 16 additions & 2 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>
@@ -34,13 +33,16 @@
3433
#include <msgpack.h>
3534

3635
#include "azure_blob.h"
37-
#include "azure_blob_db.h"
3836
#include "azure_blob_uri.h"
3937
#include "azure_blob_conf.h"
4038
#include "azure_blob_appendblob.h"
4139
#include "azure_blob_blockblob.h"
4240
#include "azure_blob_http.h"
4341

42+
#ifdef FLB_HAVE_SQLDB
43+
#include "azure_blob_db.h"
44+
#endif
45+
4446
#define CREATE_BLOB 1337
4547

4648
/* thread_local_storage for workers */
@@ -151,6 +153,7 @@ static int create_blob(struct flb_azure_blob *ctx, char *name)
151153
return FLB_OK;
152154
}
153155

156+
#ifdef FLB_HAVE_SQLDB
154157
static int delete_blob(struct flb_azure_blob *ctx, char *name)
155158
{
156159
int ret;
@@ -225,6 +228,7 @@ static int delete_blob(struct flb_azure_blob *ctx, char *name)
225228
flb_upstream_conn_release(u_conn);
226229
return FLB_OK;
227230
}
231+
#endif
228232

229233
static int http_send_blob(struct flb_config *config, struct flb_azure_blob *ctx,
230234
flb_sds_t ref_name,
@@ -380,11 +384,13 @@ static int send_blob(struct flb_config *config,
380384
uri = azb_block_blob_uri(ctx, tag, block_id, ms);
381385
ref_name = flb_sds_printf(&ref_name, "file=%s.%" PRIu64, name, ms);
382386
}
387+
#ifdef FLB_HAVE_SQLDB
383388
else if (event_type == FLB_EVENT_TYPE_BLOBS) {
384389
block_id = azb_block_blob_id_blob(ctx, name, part_id);
385390
uri = azb_block_blob_uri(ctx, name, block_id, 0);
386391
ref_name = flb_sds_printf(&ref_name, "file=%s:%" PRIu64, name, part_id);
387392
}
393+
#endif
388394
}
389395

390396
if (!uri) {
@@ -416,10 +422,12 @@ static int send_blob(struct flb_config *config,
416422
return FLB_ERROR;
417423
}
418424
}
425+
#ifdef FLB_HAVE_SQLDB
419426
else if (event_type == FLB_EVENT_TYPE_BLOBS) {
420427
payload_buf = data;
421428
payload_size = bytes;
422429
}
430+
#endif
423431

424432
ret = http_send_blob(config, ctx, ref_name, uri, block_id, event_type, payload_buf, payload_size);
425433
flb_plg_debug(ctx->ins, "http_send_blob()=%i", ret);
@@ -635,6 +643,7 @@ static int cb_azure_blob_init(struct flb_output_instance *ins,
635643
return 0;
636644
}
637645

646+
#ifdef FLB_HAVE_SQLDB
638647
static int blob_chunk_register_parts(struct flb_azure_blob *ctx, uint64_t file_id, size_t total_size)
639648
{
640649
int ret;
@@ -1034,6 +1043,7 @@ static int azb_timer_create(struct flb_azure_blob *ctx)
10341043

10351044
return 0;
10361045
}
1046+
#endif
10371047

10381048
static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk,
10391049
struct flb_output_flush *out_flush,
@@ -1081,6 +1091,7 @@ static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk,
10811091
}
10821092
}
10831093
}
1094+
#ifdef FLB_HAVE_SQLDB
10841095
else if (event_chunk->type == FLB_EVENT_TYPE_BLOBS) {
10851096
/*
10861097
* For Blob types, we use the flush callback to enqueue the file, then cb_azb_blob_file_upload()
@@ -1091,6 +1102,7 @@ static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk,
10911102
FLB_OUTPUT_RETURN(FLB_RETRY);
10921103
}
10931104
}
1105+
#endif
10941106

10951107
/* FLB_RETRY, FLB_OK, FLB_ERROR */
10961108
FLB_OUTPUT_RETURN(ret);
@@ -1129,11 +1141,13 @@ static int cb_worker_init(void *data, struct flb_config *config)
11291141
FLB_TLS_SET(worker_info, info);
11301142
}
11311143

1144+
#ifdef FLB_HAVE_SQLDB
11321145
ret = azb_timer_create(ctx);
11331146
if (ret == -1) {
11341147
flb_plg_error(ctx->ins, "failed to create upload timer");
11351148
return -1;
11361149
}
1150+
#endif
11371151

11381152
return 0;
11391153
}

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>
@@ -748,6 +752,7 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in
748752
}
749753
}
750754

755+
#ifdef FLB_HAVE_SQLDB
751756
/* database file for blob signal handling */
752757
if (ctx->database_file) {
753758
ctx->db = azb_db_open(ctx, ctx->database_file);
@@ -757,6 +762,7 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in
757762
}
758763

759764
pthread_mutex_init(&ctx->file_upload_commit_file_parts, NULL);
765+
#endif
760766

761767
flb_plg_info(ctx->ins,
762768
"account_name=%s, container_name=%s, blob_type=%s, emulator_mode=%s, endpoint=%s, auth_type=%s",
@@ -812,7 +818,9 @@ void flb_azure_blob_conf_destroy(struct flb_azure_blob *ctx)
812818
flb_upstream_destroy(ctx->u);
813819
}
814820

815-
821+
#ifdef FLB_HAVE_SQLDB
816822
azb_db_close(ctx);
823+
#endif
824+
817825
flb_free(ctx);
818826
}

0 commit comments

Comments
 (0)