25 #ifndef LOGPROTO_CLIENT_H_INCLUDED
26 #define LOGPROTO_CLIENT_H_INCLUDED
33 #define LOG_PROTO_CLIENT_OPTIONS_SIZE 128
35 typedef struct _LogProtoClientOptions
41 typedef union _LogProtoClientOptionsStorage
73 gboolean (*
poll_prepare)(LogProtoClient *s, GIOCondition *cond, GIOCondition *idle_cond, gint *timeout);
87 self->flow_control_funcs.ack_callback = flow_control_funcs->
ack_callback;
88 self->flow_control_funcs.rewind_callback = flow_control_funcs->
rewind_callback;
89 self->flow_control_funcs.user_data = flow_control_funcs->
user_data;
92 log_proto_client_msg_ack(LogProtoClient *
self, gint num_msg_acked)
94 if (
self->flow_control_funcs.ack_callback)
95 self->flow_control_funcs.ack_callback(num_msg_acked,
self->flow_control_funcs.user_data);
99 log_proto_client_msg_rewind(LogProtoClient *
self)
101 if (
self->flow_control_funcs.rewind_callback)
102 self->flow_control_funcs.rewind_callback(
self->flow_control_funcs.user_data);
111 static inline gboolean
112 log_proto_client_validate_options(LogProtoClient *
self)
114 return self->validate_options(
self);
118 log_proto_client_handshake(LogProtoClient *s, gboolean *handshake_finished)
122 return s->handshake(s, handshake_finished);
124 *handshake_finished = TRUE;
128 static inline gboolean
129 log_proto_client_poll_prepare(LogProtoClient *
self, GIOCondition *cond, GIOCondition *idle_cond, gint *timeout)
131 GIOCondition transport_cond = 0;
134 if (log_transport_stack_poll_prepare(&
self->transport_stack, &transport_cond))
137 result =
self->poll_prepare(
self, cond, idle_cond, timeout);
139 if (!
result && *timeout < 0)
140 *timeout =
self->options->super.idle_timeout;
144 if (transport_cond != 0)
145 *cond = transport_cond;
150 static inline LogProtoStatus log_proto_client_process_in(LogProtoClient *s);
153 log_proto_client_flush(LogProtoClient *
self)
156 return self->process_in(
self);
158 return self->flush(
self);
162 log_proto_client_process_in(LogProtoClient *
self)
165 return self->flush(
self);
167 return self->process_in(
self);
171 log_proto_client_post(LogProtoClient *s, LogMessage *logmsg, guchar *
msg, gsize msg_len, gboolean *consumed)
173 return s->post(s, logmsg,
msg, msg_len, consumed);
177 log_proto_client_get_fd(LogProtoClient *s)
180 return s->transport_stack.fd;
184 log_proto_client_reset_error(LogProtoClient *s)
189 static inline gboolean
190 log_proto_client_restart_with_state(LogProtoClient *s, PersistState *
state,
const gchar *persist_name)
192 if (s->restart_with_state)
193 return s->restart_with_state(s,
state, persist_name);
197 gboolean log_proto_client_validate_options(LogProtoClient *
self);
202 #define DEFINE_LOG_PROTO_CLIENT(prefix, options...) \
204 prefix ## _client_plugin_construct(Plugin *self) \
206 static LogProtoClientFactory proto = { \
207 .construct = prefix ## _client_new, \
214 #define LOG_PROTO_CLIENT_PLUGIN(prefix, __name) \
216 .type = LL_CONTEXT_CLIENT_PROTO, \
218 .construct = prefix ## _client_plugin_construct, \
221 #define LOG_PROTO_CLIENT_PLUGIN_WITH_GRAMMAR(__parser, __name) \
223 .type = LL_CONTEXT_CLIENT_PROTO, \
225 .parser = &__parser, \
237 static inline LogProtoClient *
238 log_proto_client_factory_construct(LogProtoClientFactory *
self, LogTransport *transport,
241 return self->construct(transport,
options);
244 static inline gboolean
245 log_proto_client_factory_is_proto_stateful(LogProtoClientFactory *
self)
247 return self->stateful;
const gchar * name
Definition: debugger.c:265
void log_proto_client_free_method(LogProtoClient *s)
Definition: logproto-client.c:39
void(* LogProtoClientRewindCallback)(gpointer user_data)
Definition: logproto-client.h:51
gint log_proto_client_options_get_timeout(LogProtoClientOptionsStorage *options)
Definition: logproto-client.c:75
void log_proto_client_options_defaults(LogProtoClientOptionsStorage *options)
Definition: logproto-client.c:81
#define LOG_PROTO_CLIENT_OPTIONS_SIZE
Definition: logproto-client.h:33
void log_proto_client_options_destroy(LogProtoClientOptionsStorage *options)
Definition: logproto-client.c:93
void log_proto_client_options_init(LogProtoClientOptionsStorage *options, GlobalConfig *cfg)
Definition: logproto-client.c:88
void log_proto_client_options_set_timeout(LogProtoClientOptionsStorage *options, gint timeout)
Definition: logproto-client.c:69
void log_proto_client_options_set_drop_input(LogProtoClientOptionsStorage *options, gboolean drop_input)
Definition: logproto-client.c:63
LogProtoClientFactory * log_proto_client_get_factory(PluginContext *context, const gchar *name)
Definition: logproto-client.c:98
char static_assert_size_check_LogProtoClientOptions[LOG_PROTO_CLIENT_OPTIONS_SIZE >=sizeof(LogProtoClientOptions) ? 1 :-1]
Definition: logproto-client.h:48
void log_proto_client_init(LogProtoClient *s, LogTransport *transport, const LogProtoClientOptionsStorage *options)
Definition: logproto-client.c:54
void log_proto_client_free(LogProtoClient *s)
Definition: logproto-client.c:46
void(* LogProtoClientAckCallback)(gint num_msg_acked, gpointer user_data)
Definition: logproto-client.h:50
LogProtoStatus
Definition: logproto.h:33
@ LPS_SUCCESS
Definition: logproto.h:34
@ LTIO_WRITE_WANTS_READ
Definition: logtransport.h:37
@ LTIO_READ_WANTS_WRITE
Definition: logtransport.h:35
#define self
Definition: rcptid.c:38
Definition: logproto-client.h:54
gpointer user_data
Definition: logproto-client.h:57
LogProtoClientAckCallback ack_callback
Definition: logproto-client.h:55
LogProtoClientRewindCallback rewind_callback
Definition: logproto-client.h:56
Definition: logproto-client.h:36
gboolean drop_input
Definition: logproto-client.h:37
gint idle_timeout
Definition: logproto-client.h:38
Definition: logproto-client.h:231
gboolean stateful
Definition: logproto-client.h:234
gint default_inet_port
Definition: logproto-client.h:233
Definition: logproto-client.h:69
LogProtoStatus status
Definition: logproto-client.h:70
gboolean(* validate_options)(LogProtoClient *s)
Definition: logproto-client.h:77
LogProtoStatus(* flush)(LogProtoClient *s)
Definition: logproto-client.h:76
LogProtoStatus(* process_in)(LogProtoClient *s)
Definition: logproto-client.h:75
LogProtoStatus(* post)(LogProtoClient *s, LogMessage *logmsg, guchar *msg, gsize msg_len, gboolean *consumed)
Definition: logproto-client.h:74
const LogProtoClientOptionsStorage * options
Definition: logproto-client.h:71
void(* free_fn)(LogProtoClient *s)
Definition: logproto-client.h:80
gboolean(* restart_with_state)(LogProtoClient *s, PersistState *state, const gchar *persist_name)
Definition: logproto-client.h:79
gboolean(* poll_prepare)(LogProtoClient *s, GIOCondition *cond, GIOCondition *idle_cond, gint *timeout)
Definition: logproto-client.h:73
LogTransportStack transport_stack
Definition: logproto-client.h:72
LogProtoClientFlowControlFuncs flow_control_funcs
Definition: logproto-client.h:81
LogProtoStatus(* handshake)(LogProtoClient *s, gboolean *handshake_finished)
Definition: logproto-client.h:78
GlobalConfig * cfg
Definition: test_batched_ack_tracker.c:34
CSVScannerOptions options
Definition: test_csv_scanner.c:30
GString * result
Definition: test_lexer_block.c:34
LogMessage * msg
Definition: test_rename.c:35
Definition: logproto-client.h:42
LogProtoClientOptions super
Definition: logproto-client.h:43