Skip to content

Commit

Permalink
Merge pull request #161 from MrAnno/kafka-c
Browse files Browse the repository at this point in the history
kafka: rename to kafka-c
  • Loading branch information
mochrul authored Jul 28, 2017
2 parents 3c81fcd + e846999 commit b4c624a
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion modules/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ include modules/basicfuncs-plus/Makefile.am
include modules/rss/Makefile.am
include modules/lua/Makefile.am
include modules/perl/Makefile.am
include modules/kafka/Makefile.am
include modules/kafka-c/Makefile.am
include modules/zmq/Makefile.am
include modules/grok/Makefile.am
36 changes: 36 additions & 0 deletions modules/kafka-c/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
if ENABLE_KAFKA
module_LTLIBRARIES += \
modules/kafka-c/libkafka-c.la

modules_kafka_c_libkafka_c_la_CFLAGS = \
$(RDKAFKA_CFLAGS) \
$(INCUBATOR_CFLAGS) \
-I$(top_srcdir)/modules/kafka-c \
-I$(top_builddir)/modules/kafka-c
modules_kafka_c_libkafka_c_la_SOURCES = \
modules/kafka-c/kafka-grammar.y \
modules/kafka-c/kafka.c \
modules/kafka-c/kafka.h \
modules/kafka-c/kafka-parser.h \
modules/kafka-c/kafka-parser.c

modules_kafka_c_libkafka_c_la_LIBADD = \
$(RDKAFKA_LIBS) $(INCUBATOR_LIBS)

modules_kafka_c_libkafka_c_la_LDFLAGS = \
-avoid-version -module -no-undefined

modules/kafka-c modules/kafka-c/ mod-kafka-c: \
modules/kafka-c/libkafka-c.la
else
modules/kafka-c modules/kafka-c/ mod-kafka-c:
endif

BUILT_SOURCES += \
modules/kafka-c/kafka-grammar.y \
modules/kafka-c/kafka-grammar.c \
modules/kafka-c/kafka-grammar.h
EXTRA_DIST += \
modules/kafka-c/kafka-grammar.ym

.PHONY: modules/kafka-c/ mod-kafka-c
2 changes: 1 addition & 1 deletion modules/kafka/README.md → modules/kafka-c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ destination d_kafka {
set("generic" value(".eventv1.type") condition("${.eventv1.type}" eq ""));
};
destination {
kafka(properties(metadata.broker.list("localhost:9092")
kafka-c(properties(metadata.broker.list("localhost:9092")
queue.buffering.max.ms("1000"))
topic("syslog-ng")
payload("$(format-json --key .eventv1.* --rekey .eventv1.* --shift 9)"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
extern GList *last_property;
}

%name-prefix "kafka_"
%name-prefix "kafka_c_"
%lex-param {CfgLexer *lexer}
%parse-param {CfgLexer *lexer}
%parse-param {LogDriver **instance}
%parse-param {gpointer arg}

/* INCLUDE_DECLS */

%token KW_KAFKA
%token KW_KAFKA_C
%token KW_TOPIC
%token KW_PROP
%token KW_PAYLOAD
Expand All @@ -57,7 +57,7 @@ extern GList *last_property;
%%

start
: LL_CONTEXT_DESTINATION KW_KAFKA
: LL_CONTEXT_DESTINATION KW_KAFKA_C
{
last_driver = *instance = kafka_dd_new(configuration);
last_property = NULL;
Expand Down Expand Up @@ -96,7 +96,7 @@ kafka_option
kafka_dd_set_payload(last_driver, $3);
}
| dest_driver_option
| { last_template_options = kafka_dd_get_template_options(last_driver); } template_option
| { last_template_options = kafka_dd_get_template_options(last_driver); } template_option
;

kafka_properties
Expand Down
12 changes: 6 additions & 6 deletions modules/kafka/kafka-parser.c → modules/kafka-c/kafka-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
#include "kafka-grammar.h"

extern int kafka_debug;
int kafka_parse(CfgLexer *lexer, LogDriver **instance, gpointer arg);
int kafka_c_parse(CfgLexer *lexer, LogDriver **instance, gpointer arg);

static CfgLexerKeyword kafka_keywords[] = {
{ "field", KW_FIELD },
{ "kafka", KW_KAFKA },
{ "kafka_c", KW_KAFKA_C },
{ "partition", KW_PARTITION },
{ "payload", KW_PAYLOAD },
{ "properties", KW_PROP },
Expand All @@ -40,15 +40,15 @@ static CfgLexerKeyword kafka_keywords[] = {
{ NULL }
};

CfgParser kafka_parser =
CfgParser kafka_c_parser =
{
#if ENABLE_DEBUG
.debug_flag = &kafka_debug,
#endif
.name = "kafka",
.name = "kafka-c",
.keywords = kafka_keywords,
.parse = (int (*)(CfgLexer *lexer, gpointer *instance, gpointer)) kafka_parse,
.parse = (int (*)(CfgLexer *lexer, gpointer *instance, gpointer)) kafka_c_parse,
.cleanup = (void (*)(gpointer)) log_pipe_unref,
};

CFG_PARSER_IMPLEMENT_LEXER_BINDING(kafka_, LogDriver **)
CFG_PARSER_IMPLEMENT_LEXER_BINDING(kafka_c_, LogDriver **)
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "cfg-lexer.h"
#include "kafka.h"

extern CfgParser kafka_parser;
extern CfgParser kafka_c_parser;

struct kafka_property {
gchar *key;
Expand All @@ -36,6 +36,6 @@ struct kafka_property {

void kafka_property_free(void *);

CFG_PARSER_DECLARE_LEXER_BINDING(kafka_, LogDriver **)
CFG_PARSER_DECLARE_LEXER_BINDING(kafka_c_, LogDriver **)

#endif
24 changes: 12 additions & 12 deletions modules/kafka/kafka.c → modules/kafka-c/kafka.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ kafka_log(const rd_kafka_t *rkt, int level,
const char *fac, const char *msg)
{
msg_event_suppress_recursions_and_send(
msg_event_create(level,
"Kafka internal message",
evt_tag_str("msg", msg),
msg_event_create(level,
"Kafka internal message",
evt_tag_str("msg", msg),
NULL ));
}

Expand Down Expand Up @@ -449,21 +449,21 @@ kafka_dd_init(LogPipe *s)
evt_tag_str("driver", self->super.super.super.id),
NULL);

if (self->topic == NULL)
if (self->topic == NULL)
{
msg_error("Kafka producer is not set up properly, topic name is missing",
evt_tag_str("driver", self->super.super.super.id),
NULL);
return FALSE;
}

if (self->payload == NULL)
if (self->payload == NULL)
{
self->payload = log_template_new(cfg, "default_kafka_template");
log_template_compile(self->payload, "$MESSAGE", NULL);
}

if (self->kafka == NULL)
if (self->kafka == NULL)
{
msg_error("Kafka producer is not set up properly, perhaps metadata.broker.list property is missing?",
evt_tag_str("driver", self->super.super.super.id),
Expand Down Expand Up @@ -522,17 +522,17 @@ kafka_dd_new(GlobalConfig *cfg)
return (LogDriver *)self;
}

extern CfgParser kafka_dd_parser;
extern CfgParser kafka_c_parser;

static Plugin kafka_plugin =
{
.type = LL_CONTEXT_DESTINATION,
.name = "kafka",
.parser = &kafka_parser,
.name = "kafka-c",
.parser = &kafka_c_parser,
};

gboolean
kafka_module_init(GlobalConfig *cfg, CfgArgs *args)
kafka_c_module_init(GlobalConfig *cfg, CfgArgs *args)
{
plugin_register(cfg, &kafka_plugin, 1);

Expand All @@ -541,9 +541,9 @@ kafka_module_init(GlobalConfig *cfg, CfgArgs *args)

const ModuleInfo module_info =
{
.canonical_name = "kafka",
.canonical_name = "kafka-c",
.version = SYSLOG_NG_VERSION,
.description = "The afkafka module provides Kafka destination support for syslog-ng.",
.description = "The kafka-c module provides Kafka destination support for syslog-ng.",
.core_revision = VERSION_CURRENT_VER_ONLY,
.plugins = &kafka_plugin,
.plugins_len = 1,
Expand Down
File renamed without changes.
36 changes: 0 additions & 36 deletions modules/kafka/Makefile.am

This file was deleted.

0 comments on commit b4c624a

Please sign in to comment.