scala-consul

Consul Scala Client

License

License

Categories

Categories

Scala Languages
GroupId

GroupId

com.codacy
ArtifactId

ArtifactId

scala-consul_2.11
Last Version

Last Version

3.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

scala-consul
Consul Scala Client
Project URL

Project URL

https://github.com/codacy/scala-consul
Project Organization

Project Organization

Codacy
Source Code Management

Source Code Management

https://github.com/codacy/scala-consul

Download scala-consul_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.codacy/scala-consul_2.11/ -->
<dependency>
    <groupId>com.codacy</groupId>
    <artifactId>scala-consul_2.11</artifactId>
    <version>3.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.codacy/scala-consul_2.11/
implementation 'com.codacy:scala-consul_2.11:3.0.1'
// https://jarcasting.com/artifacts/com.codacy/scala-consul_2.11/
implementation ("com.codacy:scala-consul_2.11:3.0.1")
'com.codacy:scala-consul_2.11:jar:3.0.1'
<dependency org="com.codacy" name="scala-consul_2.11" rev="3.0.1">
  <artifact name="scala-consul_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.codacy', module='scala-consul_2.11', version='3.0.1')
)
libraryDependencies += "com.codacy" % "scala-consul_2.11" % "3.0.1"
[com.codacy/scala-consul_2.11 "3.0.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.8
com.typesafe.play : play-json_2.11 jar 2.5.8
com.typesafe.play : play-ws_2.11 jar 2.5.8

Project Modules

There are no modules declared in this project.

scala-consul

Unmaintained

Codacy is not using consul at the moment and for that reason we are not developing this library any more. Feel free to fork this and keep your own code.

Alternatives

Codacy Badge Circle CI Maven Central

An asynchronous Scala (http://scala-lang.org/) client for Consul (https://consul.io/)

on an sbt project add this line to your build.sbt:

libraryDependencies += "com.codacy" %% "scala-consul" % "1.1.0"

import Consul

import consul.Consul

instanciate a consul supplying an ip and a port indicating a working consul agent:

val myConsul = new consul.Consul(CONSUL_IP, CONSUL_PORT, Option(CONSUL_ACL_TOKEN))
import myConsul.v1._

now you can use the consul API as indicated in the official documentation (http://www.consul.io/docs/agent/http.html)

Example - add a tuple to the Key/Value store:

kv.put("myKey","myValue")

Example - query the registered nodes:

catalog.nodes().map{ case nodes =>
    //do something with my nodes
}

Example - register a service with an http-check on the local node:

val myAddress = "127.0.0.1"
val myServicePort = 5000
val myServiceCheck = agent.service.httpCheck(s"http://localhost:$myServicePort/health","15s")
val myService = agent.service.LocalService(ServiceId("myServiceId"),ServiceType("myTypeOfService"),Set(ServiceTag("MyTag")),Some(myServicePort),Some(myServiceCheck),Some(Address(myAddress)))
agent.service.register(myService)

the check ID of the registered service-check is available via:

val myCheckId = myService.checkId

the other 2 types of checks are created with:

agent.service.ttlCheck

and

agent.service.scriptCheck

Error Handling:

All api methods return Futures that can fail. To parse Consul responses Play's Json library is used. In the unlikely case that the client cannot parse the response the Future will fail and you might want to access the JsError parsing resulted in. You can do so by recovering the Future:

import consul.v1.common.Types.ConsulResponseParseException
catalog.nodes().recover{
  case ConsulResponseParseException(jsError) =>  //do something with the JsError
  case NonFatal(otherException) => //something else
}

What is Codacy?

Codacy is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews.

Among Codacy’s features:

  • Identify new Static Analysis issues
  • Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)
  • Auto-comments on Commits and Pull Requests
  • Integrations with Slack, HipChat, Jira, YouTrack
  • Track issues in Code Style, Security, Error Proneness, Performance, Unused Code and other categories

Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity.

Codacy supports PHP, Python, Ruby, Java, JavaScript, and Scala, among others.

Free for Open Source

Codacy is free for Open Source projects.

Licence

This software is licensed under the Apache 2 license: http://www.apache.org/licenses/LICENSE-2.0

Copyright (C) 2014 Codacy (https://www.codacy.com)

com.codacy

Codacy

Versions

Version
3.0.1
3.0.0
2.0.2
2.0.1
2.0.0
1.1.0
1.0.1
1.0