Skip to content

Commit 20ebb42

Browse files
authored
feat: Init logger, add initial MemDB plugin (#70)
Beginning of #5. Started implementing a MemDB plugin, but other things got in the way: 1. Dropped the plugin builder as it makes it harder to extend it (I found https://projectlombok.org/features/experimental/SuperBuilder but didn't dig deeper) 2. Looks like we shouldn't throw in the serve command so the caller can use the return value and do `System.exit(exitCode)` 3. Removed the docs command as now the CLI does it 4. Initialized the logger via code using `log4j2` (couldn't find an easier way to support JSON logging)
1 parent 9abfbaf commit 20ebb42

File tree

13 files changed

+131
-96
lines changed

13 files changed

+131
-96
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Ryan Uber
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Glob Matching Library
2+
3+
This glob-matching library was copied from [ryanuber/go-glob](https://github.com/ryanuber/go-glob) and therefore falls under its [license](LICENSE).

lib/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id 'java-library'
3-
id "io.freefair.lombok" version "8.1.0"
3+
id "io.freefair.lombok" version "8.2.2"
44
id "maven-publish"
55
}
66

@@ -36,6 +36,9 @@ dependencies {
3636
implementation "io.cloudquery:plugin-pb-java:0.0.5"
3737
implementation "org.apache.arrow:arrow-vector:12.0.1"
3838

39+
implementation 'org.apache.logging.log4j:log4j-api:2.20.0'
40+
implementation 'org.apache.logging.log4j:log4j-core:2.20.0'
41+
3942
testImplementation(platform('org.junit:junit-bom:5.10.0'))
4043
testImplementation('org.junit.jupiter:junit-jupiter:5.10.0')
4144
testImplementation('org.junit.jupiter:junit-jupiter-api:5.10.0')
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.cloudquery;
2+
3+
import io.cloudquery.memdb.MemDB;
4+
import io.cloudquery.server.PluginServe;
5+
6+
public class Main {
7+
public static void main(String[] args) {
8+
PluginServe serve = PluginServe.builder().plugin(new MemDB()).args(args).build();
9+
int exitCode = serve.Serve();
10+
System.exit(exitCode);
11+
}
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.cloudquery.memdb;
2+
3+
import io.cloudquery.plugin.Plugin;
4+
5+
public class MemDB extends Plugin {
6+
public MemDB() {
7+
super("memdb", "0.0.1");
8+
}
9+
}
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
package io.cloudquery.plugin;
22

3-
import lombok.Builder;
3+
import lombok.AllArgsConstructor;
44
import lombok.Getter;
55
import lombok.NonNull;
66

7-
@Builder(builderMethodName = "innerBuilder")
87
@Getter
9-
public class Plugin {
10-
public static PluginBuilder builder(String name, String version) {
11-
return innerBuilder().name(name).verion(version);
12-
}
13-
8+
@AllArgsConstructor
9+
public abstract class Plugin {
1410
@NonNull
15-
private final String name;
11+
protected final String name;
1612
@NonNull
17-
private final String verion;
13+
protected final String version;
1814
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package io.cloudquery.scheduler;
2+
3+
public class Scheduler {
4+
public Scheduler() {
5+
}
6+
}

lib/src/main/java/io/cloudquery/server/DocCommand.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/src/main/java/io/cloudquery/server/PluginServe.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,14 @@
66
import lombok.NonNull;
77
import picocli.CommandLine;
88

9-
import java.util.ArrayList;
10-
import java.util.List;
11-
129
@Builder(access = AccessLevel.PUBLIC)
1310
public class PluginServe {
1411
@NonNull
1512
private final Plugin plugin;
1613
@Builder.Default
17-
private List<String> args = new ArrayList<>();
18-
private boolean destinationV0V1Server;
19-
private String sentryDSN;
20-
private boolean testListener;
21-
//TODO: Allow a test listener to be passed in
22-
// testListenerConn *bufconn.Listener
14+
private String[] args = new String[] {};
2315

24-
public void Serve() throws ServerException {
25-
int exitStatus = new CommandLine(new RootCommand()).
26-
addSubcommand("serve", new ServeCommand(plugin)).
27-
addSubcommand("doc", new DocCommand()).
28-
execute(args.toArray(new String[]{}));
29-
if (exitStatus != 0) {
30-
throw new ServerException("error processing command line exit status = "+exitStatus);
31-
}
16+
public int Serve() {
17+
return new CommandLine(new RootCommand()).addSubcommand(new ServeCommand(plugin)).execute(args);
3218
}
3319
}

lib/src/main/java/io/cloudquery/server/RootCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
@CommandLine.Command
66
public class RootCommand {
7-
}
7+
}

0 commit comments

Comments
 (0)