class HoundDog::Service

Defined in:

hound-dog/service.cr

Constant Summary

Log = ::Log.for(self)

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(service : String, name : String, uri : URI | String) #

[View source]

Class Method Detail

def self.clear_namespace(client : Etcd::Client | Nil = nil) #

Remove all keys beneath namespace


[View source]
def self.name_from_key(key : String) #

Extract node name from key


[View source]
def self.namespace : String #

Namespace under which all services are registered in etcd


[View source]
def self.node(key : String, value : String) : Node #

Construct a node


[View source]
def self.nodes(service, client : Etcd::Client | Nil = nil) : Array(Node) #

List nodes under a service namespace


[View source]
def self.parse_event(event : Etcd::Model::WatchEvent) : Event #

[View source]
def self.services(client : Etcd::Client | Nil = nil) #

List available services


[View source]
def self.watch(service, &block : Event -> ) #

Synchronous interface


[View source]

Instance Method Detail

def clear_namespace #

Remove all keys beneath namespace


[View source]
def etcd(retry : Bool = true, max_elapsed_time : Time::Span = 30.seconds, & : Etcd::Client -> _) #

[View source]
def lease_id : Int64 | Nil #

Lease id for service registration in Etcd


[View source]
def monitor(&callback : Event -> ) #

Start monitoring the service namespace


[View source]
def name : String #

[View source]
def node : Node #

[View source]
def nodes : Array(Node) #

List nodes under a service namespace


[View source]
def register(ttl : Int64 = HoundDog.settings.etcd_ttl) #

Registers a node under a service namespace, passing events under namespace to the callback Check for a existing key-value, and renews its lease if present Effects

  • Sets node key under service namespace
  • Spawns a fiber to maintain the lease

[View source]
def registered? #

[View source]
def registration_channel : Channel(Int64) #

[View source]
def service : String #

[View source]
def services #

List available services


[View source]
def unmonitor #

Stop monitoring the service namespace


[View source]
def unregister #

Unregister current service node


[View source]
def uri : URI #

[View source]