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 typedef struct _LogSchedulerBatch
35 {
36  struct iv_list_head elements;
37  struct iv_list_head list;
39 
40 typedef struct _LogSchedulerPartition
41 {
42  GMutex batches_lock;
43  struct iv_list_head batches;
44  gboolean flush_running;
46  LogPipe *front_pipe;
48 
49 typedef struct _LogSchedulerThreadState
50 {
52  struct iv_list_head *batch_by_partition;
53 
54  guint64 num_messages;
58 
59 typedef struct _LogSchedulerOptions
60 {
62  gint batch_size;
63  LogTemplate *partition_key;
65 
66 typedef struct _LogScheduler
67 {
68  LogPipe *front_pipe;
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);
83 void log_scheduler_options_set_num_partitions(LogSchedulerOptions *options, gint num_partitions);
84 void log_scheduler_options_set_batch_size(LogSchedulerOptions *options, gint batch_size);
86 gboolean log_scheduler_options_init(LogSchedulerOptions *options, GlobalConfig *cfg);
88 
89 #endif
gboolean log_scheduler_init(LogScheduler *self)
Definition: logscheduler.c:370
void log_scheduler_deinit(LogScheduler *self)
Definition: logscheduler.c:383
void log_scheduler_options_set_partition_key_ref(LogSchedulerOptions *options, LogTemplate *partition_key)
Definition: logscheduler.c:414
void log_scheduler_push(LogScheduler *self, LogMessage *msg, const LogPathOptions *path_options)
Definition: logscheduler.c:388
void log_scheduler_options_set_num_partitions(LogSchedulerOptions *options, gint num_partitions)
Definition: logscheduler.c:448
gboolean log_scheduler_options_init(LogSchedulerOptions *options, GlobalConfig *cfg)
Definition: logscheduler.c:470
void log_scheduler_options_destroy(LogSchedulerOptions *options)
Definition: logscheduler.c:486
void log_scheduler_options_defaults(LogSchedulerOptions *options)
Definition: logscheduler.c:462
void log_scheduler_free(LogScheduler *self)
Definition: logscheduler.c:405
LogScheduler * log_scheduler_new(LogSchedulerOptions *options, LogPipe *front_pipe)
Definition: logscheduler.c:394
void log_scheduler_options_set_batch_size(LogSchedulerOptions *options, gint batch_size)
Definition: logscheduler.c:456
Definition: logscheduler.h:35
Definition: logscheduler.h:60
gint batch_size
Definition: logscheduler.h:62
gint num_partitions
Definition: logscheduler.h:61
LogTemplate * partition_key
Definition: logscheduler.h:63
Definition: logscheduler.h:41
MainLoopIOWorkerJob io_job
Definition: logscheduler.h:45
gboolean flush_running
Definition: logscheduler.h:44
LogPipe * front_pipe
Definition: logscheduler.h:46
Definition: logscheduler.h:50
guint64 num_messages
Definition: logscheduler.h:54
gint last_partition
Definition: logscheduler.h:55
gint batch_countdown
Definition: logscheduler.h:56
struct iv_list_head * batch_by_partition
Definition: logscheduler.h:52
WorkerBatchCallback batch_callback
Definition: logscheduler.h:51
Definition: logscheduler.h:67
LogSchedulerThreadState * thread_states
Definition: logscheduler.h:72
gint num_threads
Definition: logscheduler.h:70
LogSchedulerPartition * partitions
Definition: logscheduler.h:71
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