EricJoy2048 commented on issue #3272:
URL: 
https://github.com/apache/incubator-seatunnel/issues/3272#issuecomment-1301558940

   > `org.apache.seatunnel.api.table.factory.Factory` can be used directly, 
this can also support the options of catalog and format. (can see #2490), I 
think this is necessary.
   > 
   > **Discover the existing source, sink, and catalog**
   > 
   > ```java
   > // org.apache.seatunnel.api.table.factory.FactoryUtil#discoverFactories
   >     public static <T extends Factory> List<T> 
discoverFactories(ClassLoader classLoader, Class<T> factoryClass) {
   >         final List<Factory> factories = discoverFactories(classLoader);
   >         return factories.stream()
   >                 .filter(f -> factoryClass.isAssignableFrom(f.getClass()))
   >                 .map(f -> (T) f)
   >                 .collect(Collectors.toList());
   >     }
   > ```
   > 
   > **Gets a list of options for a source**
   > 
   > ```java
   > // org.apache.seatunnel.api.table.factory.FactoryUtil#discoverFactory
   > // example for kafka source
   > OptionRule rule = 
FactoryUtil.discoverFactory(Thread.currentThread().getContextClassLoader(), 
TableSourceFactory.class, "kafka")
   >     .optionRule();
   > ```
   > 
   > **Option rule example**
   > 
   > @hk-lrzy The option rule contains a list of options
   > 
   > ```java
   >  // option example
   >  Option<String> TEST_TOPIC_PATTERN = Options.key("option.topic-pattern")
   >         .stringType()
   >         .noDefaultValue()
   >         .withDescription("test string type");
   > 
   >  // simple rule
   >  OptionRule simpleRule = OptionRule.builder()
   >      .optional(POLL_TIMEOUT, POLL_INTERVAL)
   >      .required(CLIENT_SERVICE_URL)
   >      .build();
   >  
   >  // basic full rule
   >  OptionRule fullRule = OptionRule.builder()
   >      .optional(POLL_TIMEOUT, POLL_INTERVAL, CURSOR_STARTUP_MODE)
   >      .required(CLIENT_SERVICE_URL, ADMIN_SERVICE_URL)
   >      .exclusive(TOPIC_PATTERN, TOPIC)
   >      .conditional(CURSOR_STARTUP_MODE, StartMode.TIMESTAMP, 
CURSOR_STARTUP_TIMESTAMP)
   >      .build();
   >  
   >  // complex conditional rule
   >  // moot expression
   >  Expression expression = Expression.of(TOPIC_DISCOVERY_INTERVAL, 200)
   >      .and(Expression.of(Condition.of(CURSOR_STARTUP_MODE, 
StartMode.EARLIEST)
   >          .or(CURSOR_STARTUP_MODE, StartMode.LATEST)))
   >      .or(Expression.of(Condition.of(TOPIC_DISCOVERY_INTERVAL, 100)))
   >  
   >  OptionRule complexRule = OptionRule.builder()
   >      .optional(POLL_TIMEOUT, POLL_INTERVAL, CURSOR_STARTUP_MODE)
   >      .required(CLIENT_SERVICE_URL, ADMIN_SERVICE_URL)
   >      .exclusive(TOPIC_PATTERN, TOPIC)
   >      .conditional(expression, CURSOR_RESET_MODE)
   >      .build();
   > ```
   
   Yes, I see. I will use `Factory `.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to