All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.streamthoughts.kafka.specs.command.WithAdminClientCommand Maven / Gradle / Ivy

The newest version!
package io.streamthoughts.kafka.specs.command;

import io.streamthoughts.kafka.specs.KafkaSpecs;
import io.streamthoughts.kafka.specs.internal.AdminClientUtils;
import org.apache.kafka.clients.admin.AdminClient;
import picocli.CommandLine;
import picocli.CommandLine.ParentCommand;

import java.util.function.Function;

public class WithAdminClientCommand {

    @ParentCommand
    private KafkaSpecs specs;

    public Integer withAdminClient(final Function function) {
        try (AdminClient client = AdminClientUtils.newAdminClient(
                specs.options.bootstrapServer,
                specs.options.clientCommandConfig,
                specs.options.clientCommandProperties
        )) {
            return function.apply(client);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy