Last active
February 25, 2022 08:28
-
-
Save arehmandev/f4c5dd59fae12d66a1ec8a5f7d2ce5e6 to your computer and use it in GitHub Desktop.
Store keyvalue pair in Consul using groovy (java Ecwid/consul-api)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab( 'com.ecwid.consul:consul-api:1.2.4' ) | |
import com.ecwid.consul.v1.* | |
client = new ConsulClient("172.20.20.10:8500") | |
setvalue("Abskey", "Absvalue") | |
println getvalue("Abskey") | |
def setvalue(String key, value){ | |
def binaryvalue = value as byte[] | |
client.setKVBinaryValue(key, binaryvalue) | |
println("Value set") | |
} | |
def getvalue(String key) { | |
def keyValueResponse = client.getKVValue(key) | |
def response = keyValueResponse.getValue().getDecodedValue() | |
return response | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment