The chili core is an opinionated framework for creating microservices with focus on speed of development and time to market. It's based on the Vert.x toolkit for maximum power and uses Hazelcast for plug-and-play clustering. This project is small with only 22k LOC.
Find the official documentation here.
Using gradle
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compile "com.github.codingchili.chili-core:core:<version>"
}
Creating a new handler
@Role(PUBLIC)
@Address("api")
public class MyHandler implements CoreHandler {
private Protocol<Request> protocol = new Protocol<>(this);
@Api
public void list(Request request) {
request.write(new ArrayList<>(Arrays.asList("hello", "world")));
}
@Override
public void handle(Request request) {
protocol.process(request);
}
}
Deploying a handler with the REST listener on port 8080 (default).
public static void main(String[] args) {
ListenerSettings settings = new ListenerSettings()
.setPort(8080)
.setSecure(false);
CoreContext core = new SystemContext();
core.listener(() -> new RestListener()
.settings(settings)
.handler(new MyHandler()));
}
Start it up and check the service with
curl -v http://localhost:8080/api/list
To build chili-core clone this repository with git,
git clone https://github.com/codingchili/chili-core.git
Builds project jars and run tests
gradlew build
Note: when targeting java 9+ the following hacks are needed for Netty/Vert.x
--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/sun.net.dns=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED
The purpose of wrapping vertx in a framework is to increase productivity. This is done by providing common functionality that can be used to build microservices on as a framework. With all the logic packed into core, it is possible to create distributed microservices capable of handling authentication, request routing and storage in 66 lines of code. If you are interested in vertx, I recommend using it directly instead. This framework is intended to improve productivity for a single developer, aka the author. In order to achieve this it is much more invasive than the vertx toolkit.
The complete feature list may change during development.
The core uses some great software, such as
Optional dependencies
Read the documentation to learn more about optional dependencies.
Applications currently using chili-core
application | description |
---|---|
mutable-bunnies | 2D MMORPG game in development. |
zapperfly-asm | Extra simple clustered build servers. |
ethereum-ingest | Ethereum block/transaction import utility. |
flashcards | Progressive web app for studying with flashcards. |
Issues and PR's are welcome with :blue_heart:.
The MIT License (MIT) Copyright (c) 2019 Robin Duda
See: License