@@ -12,20 +12,9 @@ public class EventSender {
12
12
private String insertScript ;
13
13
private EventHandler eventHandler ;
14
14
private DBConnection conn ;
15
- private boolean isConnected ;
16
15
17
- public EventSender (List <EventSchema > eventSchemas , List <String > eventTimeKeys , List <String > commonKeys ) {
16
+ public EventSender (DBConnection conn , String tableName , List <EventSchema > eventSchemas , List <String > eventTimeKeys , List <String > commonKeys ) throws IOException {
18
17
this .eventHandler = new EventHandler (eventSchemas , eventTimeKeys , commonKeys );
19
- this .isConnected = false ;
20
- }
21
-
22
- public void connect (DBConnection conn , String tableName ) throws IOException {
23
- if (this .isConnected )
24
- throw new RuntimeException ("The eventSender has already been called." );
25
-
26
- if (!conn .isConnected ())
27
- throw new RuntimeException ("The connection to dolphindb has not been established." );
28
-
29
18
this .conn = conn ;
30
19
31
20
String sql = "select top 0 * from " + tableName ;
@@ -35,13 +24,9 @@ public void connect(DBConnection conn, String tableName) throws IOException {
35
24
throw new RuntimeException (errMsg .toString ());
36
25
37
26
this .insertScript = "tableInsert{" + tableName + "}" ;
38
- this .isConnected = true ;
39
27
}
40
28
41
29
public void sendEvent (String eventType , List <Entity > attributes ) {
42
- if (!isConnected )
43
- throw new RuntimeException ("This eventSender has not connected to the dolphindb" );
44
-
45
30
List <Entity > args = new ArrayList <>();
46
31
StringBuilder errMsg = new StringBuilder ();
47
32
@@ -55,8 +40,4 @@ public void sendEvent(String eventType, List<Entity> attributes) {
55
40
}
56
41
}
57
42
58
- public static EventSender createEventSender (List <EventSchema > eventSchemas , List <String > eventTimeKeys , List <String > commonKeys ) {
59
- return new EventSender (eventSchemas , eventTimeKeys , commonKeys );
60
- }
61
-
62
43
}
0 commit comments