Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nryanov/consul4s
A native Scala client for interacting with Consul built on top of sttp-client.
https://github.com/nryanov/consul4s
client consul consul-api scala sttp
Last synced: 10 days ago
JSON representation
A native Scala client for interacting with Consul built on top of sttp-client.
- Host: GitHub
- URL: https://github.com/nryanov/consul4s
- Owner: nryanov
- License: apache-2.0
- Created: 2020-05-07T20:09:41.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-26T16:40:43.000Z (11 days ago)
- Last Synced: 2024-10-27T06:07:25.231Z (11 days ago)
- Topics: client, consul, consul-api, scala, sttp
- Language: Scala
- Homepage:
- Size: 595 KB
- Stars: 6
- Watchers: 3
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# consul4s
[![GitHub license](https://img.shields.io/github/license/nryanov/consul4s)](https://github.com/nryanov/consul4s/blob/master/LICENSE.txt)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.nryanov.consul4s/consul4s-core_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.nryanov.consul4s/consul4s-core_2.13)
A native Scala client for interacting with Consul built on top of [sttp-client](https://github.com/softwaremill/sttp).## Features
Currently `consul4s` supports these endpoints:
- agent
- catalog
- coordinate
- event
- health
- kv
- prepared queries (only existing query execution)
- session
- status
- transaction## Modules
Consul4s uses multi-project structure and contains of the following modules_:* [`consul4s-core`](modules/core) - core classes/functions
* [`consul4s-circe`](modules/circe) - circe integration
* [`consul4s-json4s`](modules/json4s) - json4s integration
* [`consul4s-spray-json`](modules/spray-json) - spray-json integration## Installation
consul4s is published for Scala 2.13 and 2.12 to Maven Central, so just add the following to your build.sbt:```sbt
libraryDependencies ++= Seq(
"com.nryanov.consul4s" %% "consul4s-core" % "[version]",
// And one of the following:
"com.nryanov.consul4s" %% "consul4s-circe" % "[version]",
"com.nryanov.consul4s" %% "consul4s-json4s" % "[version]",
"com.nryanov.consul4s" %% "consul4s-spray-json" % "[version]",
)
```Also you can add any sttp-client backend you want.
## Getting Started
Without any additional dependencies you can use the default `HttpURLConnectionBackend` as backend for requests. But sttp also supports other backend implementations:
> STTP: Backend implementations include ones based on [akka-http](https://doc.akka.io/docs/akka-http/current/scala/http/), [async-http-client](https://github.com/AsyncHttpClient/async-http-client), [http4s](https://http4s.org), [OkHttp](http://square.github.io/okhttp/), and HTTP clients which ship with Java. They integrate with [Akka](https://akka.io), [Monix](https://monix.io), [fs2](https://github.com/functional-streams-for-scala/fs2), [cats-effect](https://github.com/typelevel/cats-effect), [scalaz](https://github.com/scalaz/scalaz) and [ZIO](https://github.com/zio/zio).```scala
import consul4s.v1._
import consul4s.circe._
import sttp.client.HttpURLConnectionBackendobject Main {
def main(args: Array[String]): Unit = {
val backend = HttpURLConnectionBackend()
val client = ConsulClient(backend) // will use default host and port: http://localhost:8500for {
datacenters <- client.getDatacenters().body
} yield datacenters
}
}
```