kafka StringConverterConfig 源码

  • 2022-10-20
  • 浏览 (291)

kafka StringConverterConfig 代码

文件路径:/connect/api/src/main/java/org/apache/kafka/connect/storage/StringConverterConfig.java

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */
package org.apache.kafka.connect.storage;

import org.apache.kafka.common.config.ConfigDef;
import org.apache.kafka.common.config.ConfigDef.Importance;
import org.apache.kafka.common.config.ConfigDef.Type;
import org.apache.kafka.common.config.ConfigDef.Width;

import java.nio.charset.StandardCharsets;
import java.util.Map;

/**
 * Configuration options for {@link StringConverter} instances.
 */
public class StringConverterConfig extends ConverterConfig {

    public static final String ENCODING_CONFIG = "converter.encoding";
    public static final String ENCODING_DEFAULT = StandardCharsets.UTF_8.name();
    private static final String ENCODING_DOC = "The name of the Java character set to use for encoding strings as byte arrays.";
    private static final String ENCODING_DISPLAY = "Encoding";

    private final static ConfigDef CONFIG;

    static {
        CONFIG = ConverterConfig.newConfigDef();
        CONFIG.define(ENCODING_CONFIG, Type.STRING, ENCODING_DEFAULT, Importance.HIGH, ENCODING_DOC, null, -1, Width.MEDIUM,
                      ENCODING_DISPLAY);
    }

    public static ConfigDef configDef() {
        return CONFIG;
    }

    public StringConverterConfig(Map<String, ?> props) {
        super(CONFIG, props);
    }

    /**
     * Get the string encoding.
     *
     * @return the encoding; never null
     */
    public String encoding() {
        return getString(ENCODING_CONFIG);
    }
}

相关信息

kafka 源码目录

相关文章

kafka Converter 源码

kafka ConverterConfig 源码

kafka ConverterType 源码

kafka HeaderConverter 源码

kafka OffsetStorageReader 源码

kafka SimpleHeaderConverter 源码

kafka StringConverter 源码

0  赞