001/** 002 * Copyright (C) 2006-2025 Talend Inc. - www.talend.com 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.talend.sdk.component.runtime.manager.chain; 017 018import java.util.function.Consumer; 019 020import org.talend.sdk.component.runtime.input.CheckpointState; 021import org.talend.sdk.component.runtime.manager.chain.internal.DSLParser; 022import org.talend.sdk.component.runtime.manager.chain.internal.JobImpl; 023 024import lombok.Data; 025 026public interface Job { 027 028 static ComponentBuilder components() { 029 return new JobImpl.NodeBuilderImpl(); 030 } 031 032 interface ComponentBuilder { 033 034 NodeBuilder component(final String id, String uri); 035 } 036 037 interface NodeBuilder extends ComponentBuilder { 038 039 NodeBuilder property(String name, Object value); 040 041 NodeBuilder checkpoint(Consumer<CheckpointState> checkpoint); 042 043 FromBuilder connections(); 044 } 045 046 interface FromBuilder { 047 048 ToBuilder from(String id, String branch); 049 050 default ToBuilder from(String id) { 051 return from(id, "__default__"); 052 } 053 054 } 055 056 interface ToBuilder { 057 058 Builder to(String id, String branch); 059 060 default Builder to(String id) { 061 return to(id, "__default__"); 062 } 063 } 064 065 interface Builder extends FromBuilder { 066 067 ExecutorBuilder build(); 068 } 069 070 interface ExecutorBuilder { 071 072 ExecutorBuilder property(String name, Object value); 073 074 void run(); 075 } 076 077 @Data 078 class Component { 079 080 private final String id; 081 082 private boolean isSource = false; 083 084 private final DSLParser.Step node; 085 086 private Consumer<CheckpointState> checkpointCallback; 087 } 088 089 @Data 090 class Connection { 091 092 private final Component node; 093 094 private final String branch; 095 } 096 097 @Data 098 class Edge { 099 100 private final Connection from; 101 102 private final Connection to; 103 } 104 105}