Our great sponsors
-
kt-search
Multi platform kotlin client for Elasticsearch & Opensearch with easily extendable Kotlin DSLs for queries, mappings, bulk, and more.
-
kt-search-kts
Adds kts scripting to kt-search and provides some convenience around using that from kts.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Whatever you are dealing with, you can create a Kotlin DSL for it. If you have any Json dialect, checkout my JsonDsl library, which is part of kt-search. With that you can create simple Kotlin classes to model your DSL using type safe properties and have a run-time modifiable map to add anything it doesn't model. Creating a Yaml version of this is very straightforward and likely something I might do at some point (pull requests welcome).
So, that was easily remedied and I now have a companion library that combines that with kotlinx-cli to make writing scripts very straightforward.
One of my team members, Nikky, got annoyed with the verbosity and insane amount of copy-paste reuse needed to drive Github Actions. And true to her nature, promptly fixed it by using and contributing to GitHub Actions Kotlin DSL
#!/usr/bin/env kotlin @file:Repository("https://jitpack.io") @file:Repository("https://maven.tryformation.com/releases") @file:DependsOn("com.github.jillesvangurp:kt-search-kts:0.1.3") import com.jillesvangurp.ktsearch.ClusterStatus import com.jillesvangurp.ktsearch.clusterHealth import com.jillesvangurp.ktsearch.kts.addClientParams import com.jillesvangurp.ktsearch.kts.searchClient import com.jillesvangurp.ktsearch.root import kotlinx.cli.ArgParser import kotlinx.coroutines.runBlocking val parser = ArgParser("script") val searchClientParams = parser.addClientParams() parser.parse(args) val client = searchClientParams.searchClient // now use the client as normally in a runBlocking block runBlocking { val clusterStatus=client.clusterHealth() client.root().let { rootResp -> println( """ Cluster name: ${rootResp.clusterName} Search Engine distribution: ${rootResp.version.distribution} Version: ${rootResp.version.number} Status: ${clusterStatus.status} """.trimIndent() ) } }