This is unonfficially repository of Consul by Hashicorp client for Deno
Funcional
- KV Store
- Get Members Node
- Service Registration
- Get Service
- Support Consul Token
To Do:
- TLS consul config
- etc
Feel Free to Contribute thank you
import { Consul, ConsulClient, ConsulKV, ClientDefaultConfig, ServiceConfig, ConsulService, Check } from "https://deno.land/x/consul/mod.ts"
import { Consul, ConsulClient, ConsulKV, ClientDefaultConfig, ServiceConfig, ConsulService, Check } from "https://deno.land/x/[email protected]/mod.ts"
const consulConfig = <ConsulClient>{
hostname : "localhost",
port : 8080,
}
const consul = new Consul(consulConfig);
const consulConfig = <ConsulClient>{
hostname : "localhost",
port : 8080,
}
const consul = new Consul(consulConfig);
await consul.getValue("foo").then((res:string)=>{
console.log(res)
})
const consulConfig = <ConsulClient>{
hostname : "localhost",
port : 8080,
}
const consul = new Consul(consulConfig);
var data = <ConsulKV>{
Key: "foo",
Value: "bar"
}
await consul.putKey(data).then((res:boolean)=>{
console.log(res)
})
var check = <Check>{
HTTP : "http://localhost:8080",
Method: "GET",
Interval: "10s",
DeregisterCriticalServiceAfter: "5m"
}
var service = <ServiceConfig> {
ID: "test",
Name: "test-service",
Port: 8080,
Address: "127.0.0.1",
Tags: ["Cuilan"],
Check: check
}
const newservice= new ConsulService(service);
const consul = new Consul(ClientDefaultConfig());
await consul.registerService(newservice.serviceConf);
await consul.getServiceCatalog().then((res)=>{
console.log(res)
})