Skip to content

Commit

Permalink
kafka-event-sink: bind resources in a module
Browse files Browse the repository at this point in the history
  • Loading branch information
ibodrov committed Nov 9, 2023
1 parent d890f5f commit 46bef23
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;

@Named
@Singleton
public class KafkaConnector implements BackgroundTask {

private static final Logger log = LoggerFactory.getLogger(KafkaConnector.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import javax.inject.Named;
import java.util.Collections;
import java.util.List;

@Named
public class KafkaEventSink implements ProcessEventListener, ProcessLogListener, AuditLogListener {

private static final Logger log = LoggerFactory.getLogger(KafkaEventSink.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;

@Named
public class KafkaEventSinkConfiguration implements Serializable {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.walmartlabs.concord.server.plugins.eventsink.kafka;

/*-
* *****
* Concord
* -----
* Copyright (C) 2017 - 2023 Walmart Inc.
* -----
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =====
*/

import com.google.inject.Binder;
import com.google.inject.Module;
import com.walmartlabs.concord.server.sdk.BackgroundTask;
import com.walmartlabs.concord.server.sdk.audit.AuditLogListener;
import com.walmartlabs.concord.server.sdk.events.ProcessEventListener;
import com.walmartlabs.concord.server.sdk.log.ProcessLogListener;

import javax.inject.Named;

import static com.google.inject.Scopes.SINGLETON;
import static com.google.inject.multibindings.Multibinder.newSetBinder;

@Named
public class KafkaModule implements Module {

@Override
public void configure(Binder binder) {
binder.bind(KafkaEventSinkConfiguration.class).in(SINGLETON);

binder.bind(KafkaEventSink.class).in(SINGLETON);
newSetBinder(binder, ProcessEventListener.class).addBinding().to(KafkaEventSink.class);
newSetBinder(binder, ProcessLogListener.class).addBinding().to(KafkaEventSink.class);
newSetBinder(binder, AuditLogListener.class).addBinding().to(KafkaEventSink.class);

binder.bind(KafkaConnector.class).in(SINGLETON);
newSetBinder(binder, BackgroundTask.class).addBinding().to(KafkaConnector.class);
}
}

0 comments on commit 46bef23

Please sign in to comment.