syslog-ng source
logscheduler.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Balázs Scheidler <bazsi77@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * As an additional exemption you are allowed to compile & link against the
19  * OpenSSL libraries as published by the OpenSSL project. See the file
20  * COPYING for details.
21  *
22  */
23 
24 #ifndef LOGSCHEDULER_H_INCLUDED
25 #define LOGSCHEDULER_H_INCLUDED
26 
27 #include "logpipe.h"
28 #include "mainloop-io-worker.h"
29 #include "template/templates.h"
30 
31 #include <iv_list.h>
32 #include <iv_event.h>
33 
34 #define LOGSCHEDULER_MAX_PARTITIONS 16
35 
36 typedef struct _LogSchedulerBatch
37 {
38  struct iv_list_head elements;
39  struct iv_list_head list;
41 
42 typedef struct _LogSchedulerPartition
43 {
44  GMutex batches_lock;
45  struct iv_list_head batches;
46  gboolean flush_running;
48  LogPipe *front_pipe;
50 
51 typedef struct _LogSchedulerThreadState
52 {
53  WorkerBatchCallback batch_callback;
54  struct iv_list_head batch_by_partition[LOGSCHEDULER_MAX_PARTITIONS];
55 
56  guint64 num_messages;
59 
60 typedef struct _LogSchedulerOptions
61 {
63  LogTemplate *partition_key;
65 
66 typedef struct _LogScheduler
67 {
68  LogPipe *front_pipe;
72  LogSchedulerThreadState thread_states[];
73 } LogScheduler;
74 
75 gboolean log_scheduler_init(LogScheduler *self);
77 
78 void log_scheduler_push(LogScheduler *self, LogMessage *msg, const LogPathOptions *path_options);
79 LogScheduler *log_scheduler_new(LogSchedulerOptions *options, LogPipe *front_pipe);
81 
82 void log_scheduler_options_set_partition_key_ref(LogSchedulerOptions *options, LogTemplate *partition_key);
84 gboolean log_scheduler_options_init(LogSchedulerOptions *options, GlobalConfig *cfg);
86 
87 #endif
#define LOGSCHEDULER_MAX_PARTITIONS
Definition: logscheduler.h:34
gboolean log_scheduler_init(LogScheduler *self)
Definition: logscheduler.c:333
void log_scheduler_deinit(LogScheduler *self)
Definition: logscheduler.c:346
void log_scheduler_options_set_partition_key_ref(LogSchedulerOptions *options, LogTemplate *partition_key)
Definition: logscheduler.c:376
void log_scheduler_push(LogScheduler *self, LogMessage *msg, const LogPathOptions *path_options)
Definition: logscheduler.c:351
gboolean log_scheduler_options_init(LogSchedulerOptions *options, GlobalConfig *cfg)
Definition: logscheduler.c:390
void log_scheduler_options_destroy(LogSchedulerOptions *options)
Definition: logscheduler.c:400
void log_scheduler_options_defaults(LogSchedulerOptions *options)
Definition: logscheduler.c:383
void log_scheduler_free(LogScheduler *self)
Definition: logscheduler.c:367
LogScheduler * log_scheduler_new(LogSchedulerOptions *options, LogPipe *front_pipe)
Definition: logscheduler.c:357
Definition: logscheduler.h:37
Definition: logscheduler.h:61
gint num_partitions
Definition: logscheduler.h:62
LogTemplate * partition_key
Definition: logscheduler.h:63
Definition: logscheduler.h:43
MainLoopIOWorkerJob io_job
Definition: logscheduler.h:47
gboolean flush_running
Definition: logscheduler.h:46
LogPipe * front_pipe
Definition: logscheduler.h:48
Definition: logscheduler.h:52
guint64 num_messages
Definition: logscheduler.h:56
gint last_partition
Definition: logscheduler.h:57
Definition: logscheduler.h:67
gint num_threads
Definition: logscheduler.h:70
LogPipe * front_pipe
Definition: logscheduler.h:68
LogSchedulerOptions * options
Definition: logscheduler.h:69
Definition: mainloop-io-worker.h:32
Definition: mainloop-worker.h:53
GlobalConfig * cfg
Definition: test_batched_ack_tracker.c:34
LogMessage * msg
Definition: test_rename.c:35
LogPathOptions path_options
Definition: test_wildcard_file_reader.c:62