Based on the specification of a set of frameworks implemented by vertx, you need to use the modules to run it. Simply assemble it to implement common functions. (The project is in continuous improvement...)
Learn from the springboot configuration, what features you need, just need to import the corresponding module dependencies are directly available. For example, you need to build a http web project, import web-http; if you need to call the database, import data-hikari. You have a lot of other options, as the modules provided, you can use them. For specific use, please refer to the documentation of each module. The demo make easier understand.
If you don't like the module implementation, welcome to contribute a suitable module.
Requires JDK1.8+ support.
maven
<dependency>
<groupId>com.tollge</groupId>
<artifactId>tollge</artifactId>
<version>0.1.1</version>
</dependency>
Gradle
compile 'com.tollge:tollge:0.1.1'
tollge provides the basic specification, because based on vertx, please understand the basics of vertx first, the currently implemented modules below:
- Global vertx object
UseMyVertx.vertx()
to getVertx
object. - Global parameter
The first step is to load all moudules/tollge.yml and the configuration will save in a map of<String, String>
The same key will be overwritten, the tollge.yml in the user project will be loaded at last. - deploy verticle
You can addverticles.xxx: com.xxx.xxx.xxVerticle
in tollge.yml to deploy verticle.
Define the number of instances that need to be deployed. For example,verticles.xxxx: com.xxxx.xxxx.xxxVerticle, 10
deploy 10 xxxVerticle instances.
In addition to using numbers directly, Tollge defines two keywords,ALL'and
HALF'. `HALF' are half the number of CPU cores available. - Biz discovery
Default to load all Biz under packagecom.tollge.modules.**
You can load all Biz under thecom.xxx
package by addingapplication.baseScan: com.xxx
to tollge.yml.
What is Biz? It is a provider in vertx. tollge it is written like this:
@Biz("biz://tt")
public class HttpBiz extends BizVerticle {
/**
* test
*/
@Path("/one")
@NotNull(key="key")
public void one(Message<JsonObject> msg) {
String key = msg.body().getString("key");
msg.reply(key+" response");
}
}
- Annotation simplified code
Currently providing types of annotations below
annotation type | name | function | parameters |
---|---|---|---|
check | NotNull | check null | key: key to check. msg:message to show |
check | RegexValid | regex check | key: key to check. regex:Regular expression. msg:message to show |
check | LengthValid | length check for String and JsonArray | key: key to check. min:xx max:xx msg:message to show |
change content | InitIfNull | Initialize if the key is empty | key: key to check. value:Initialize value |
change type | ChangeType | Change data type | key: key to check. from:from type. to:to type |
- Data layer call simplification
extends BizVerticle, You can greatly simplify the code by using methods such as page, list, one, count, etc.. - Multi-level cache
Import JetCache, The tool class CacheUtil has been initially packaged. It is recommended to customize it yourself, the original is not easy to use..
See modules
Welcome everyone to provide a new module implementation.