1 package org.wikimedia.eventutilities.flink.table.catalog;
2
3 import static org.wikimedia.eventutilities.flink.formats.json.EventJsonFormatOptions.SCHEMA_VERSION;
4 import static org.wikimedia.eventutilities.flink.formats.json.EventJsonFormatOptions.STREAM_NAME;
5
6 import java.util.UUID;
7
8 import org.apache.flink.configuration.ConfigOption;
9 import org.apache.flink.configuration.ConfigOptions;
10 import org.apache.flink.streaming.connectors.kafka.table.KafkaConnectorOptions;
11 import org.apache.flink.streaming.connectors.kafka.table.KafkaDynamicTableFactory;
12 import org.apache.flink.table.factories.FactoryUtil;
13 import org.wikimedia.eventutilities.flink.formats.json.EventJsonFormatFactory;
14
15 import com.google.common.collect.ImmutableList;
16 import com.google.common.collect.ImmutableMap;
17
18 public final class EventStreamCatalogFactoryOptions {
19
20 public static final ConfigOption<String> STREAM_PREFIX =
21 ConfigOptions.key("kafka-topic-prefix")
22 .stringType()
23 .noDefaultValue()
24 .withDescription(
25 "The prefix to attach to the event stream name when using the Kafka connector."
26 );
27
28 public static final ConfigOption<String> WATERMARK_COLUMN =
29 ConfigOptions.key("kafka-watermark-column")
30 .stringType()
31 .defaultValue("kafka_timestamp")
32 .withDescription(
33 "The column name to use for Kafka watermarks." +
34 "This virtual column is automatically applied to every Kafka table in the catalog and should not be overwritten."
35 );
36
37 public static final ConfigOption<Integer> WATERMARK_DELAY =
38 ConfigOptions.key("kafka-watermark-delay")
39 .intType()
40 .defaultValue(10)
41 .withDescription(
42 "The number of seconds to delay the Kafka watermark by."
43 );
44
45
46
47
48 public static final ImmutableMap<String, String> DEFAULT_OPTIONS = ImmutableMap.<String, String>builder()
49 .put(FactoryUtil.FORMAT.key(), EventJsonFormatFactory.IDENTIFIER)
50 .put(FactoryUtil.CONNECTOR.key(), KafkaDynamicTableFactory.IDENTIFIER)
51 .build();
52
53
54
55
56 public static final ImmutableMap<String, String> DEFAULT_KAFKA_OPTIONS = ImmutableMap.<String, String>builder()
57 .put(KafkaConnectorOptions.SCAN_STARTUP_MODE.key(), "latest-offset")
58 .put(KafkaConnectorOptions.PROPS_GROUP_ID.key(), "flink_event_stream_catalog." + UUID.randomUUID().toString())
59 .build();
60
61
62
63
64 public static final ImmutableList<ConfigOption<?>> OVERRIDE_OPTIONS = ImmutableList.<ConfigOption<?>>builder()
65 .add(STREAM_NAME)
66 .add(SCHEMA_VERSION)
67 .add(WATERMARK_COLUMN)
68 .add(WATERMARK_DELAY)
69 .build();
70
71
72
73
74 public static final ImmutableList<ConfigOption<?>> PSEUDO_TABLE_OPTIONS = ImmutableList.<ConfigOption<?>>builder()
75 .add(STREAM_PREFIX)
76 .add(STREAM_NAME)
77 .add(SCHEMA_VERSION)
78 .add(WATERMARK_COLUMN)
79 .add(WATERMARK_DELAY)
80 .build();
81
82 private EventStreamCatalogFactoryOptions() {
83 }
84 }