Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

satta/balboa-backend-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

37 Commits

Repository files navigation

balboa-backend-java

Java CI Maven Central

This is a balboa backend connector for Java. It takes care of the boring msgpack deserialization and validation, and provides a pluggable interface for backends to receive input and answer queries.

Interaction with the frontend(s) is done via code implementing the InputProcessor interface, which is called for each incoming message. The methods to be implemented refer to the various message types:

@FunctionalInterface
public interface ObservationStreamConsumer
{
 void submit(Observation o) throws IOException;
}
public interface InputProcessor {
 public abstract void handle(Observation o) throws BalboaException;
 public abstract void handle(DumpRequest d) throws BalboaException;
 public abstract void handle(BackupRequest b) throws BalboaException;
 public abstract void handle(Query q, ObservationStreamConsumer submitResult) throws BalboaException, IOException;
 public abstract void close();
}

Here's the simplest forking server that starts a new processing engine for each new incoming connection and just prints incoming mesages:

public class Main {
 public static void main(String[] args) {
 ServerSocket server = new ServerSocket(4242);
 do {
 Socket socket = server.accept();
 new Thread(new BackendWorker(socket, new PrintProcessor())).start();
 } while (true);
 }
}

About

πŸ›‘ Balboa backend connector for Java

Topics

Resources

License

Stars

Watchers

Forks

Packages

Contributors

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /