Sha256: b56761f8be4841d3b210a575a780131b8c45cbb4e3b6de3de4b2ffc3217114dd
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
class NameServiceApp<Service provides :nameService requires :directoryService requires :localFileStore def initialize(cluster,ops) super(cluster,ops,:nameService) @cache={} tryLoad @cache.each{|k,v|export(k,v)} end def run wait4DS super end def get(url) wait4DS result=getApp(:directoryService).get([:nameService,url]) @cache[url]=result end def export(url,instance) @cache[url]=instance getApp(:directoryService).set([:nameService,url],instance) trySave end def clear @cache={} end def stop # FIXME: export anything to others trySave super end def content @cache end #private def wait4DS wait=2 x=0.1 while wait>0 break if getApp(:directoryService) sleep x wait-=x end end private def trySave begin retrieveConfig["cache"]=@cache rescue Object=>e pp e,e.backtrace end end def tryLoad begin @cache=retrieveConfig["cache"].content rescue Object=>e pp e,e.backtrace end @cache||={} end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
appswarm-0.0.1 | apps/name_service/name_service.rb |