Zoologist
A Curator-esque ZooKeeper framework for Node.js.
Installation
npm install zoologist --save
Examples
Service Registration
'use strict'; var Zoologist = Zoologist;var ServiceInstanceBuilder = ServiceInstanceBuilder;var ServiceDiscoveryBuilder = ServiceDiscoveryBuilder; // Clientvar zoologistClient = Zoologist; // Start the client (connect to ZooKeeper)zoologistClientstart; // Service Instancevar serviceInstance = ServiceInstanceBuilder portprocessenvPORT name'my/service/name/v1' ; // Service Discoveryvar serviceDiscovery = ServiceDiscoveryBuilder ; // Register a ServiceserviceDiscovery;
Service Discovery
'use strict'; var Zoologist = Zoologist;var ServiceInstanceBuilder = ServiceInstanceBuilder;var ServiceDiscoveryBuilder = ServiceDiscoveryBuilder; // Clientvar zoologistClient = Zoologist; // Start the client (connect to ZooKeeper)zoologistClientstart; // Service Instancevar serviceInstance = ServiceInstanceBuilder portprocessenvPORT name'my/service/name/v1' ; // Service Discoveryvar serviceDiscovery = ServiceDiscoveryBuilder ; // Service Provider (providerStrategy: 'RoundRobin' or 'Random')var serviceProvider = serviceDiscovery ; // Discover available Services and provide an instanceserviceProvider;
Leadership Election
'use strict'; var async = ; var Zoologist = Zoologist; var LeaderElection = LeaderElection; var client = Zoologist; /* * This represents how many active elections you will need at one time. * The default is 10. */client;clientstart; var election = client '/my/path' 'my-id'; electionstart{ console;}; election; election; election; election; election;