def startRouter(): if self.identification is not None: setproctitle(self.identification) router = Default( config, size=self.queue_size, frequency=self.frequency, identification=self.identification, graph=self.graph, graph_include_sys=self.graph_include_sys ) router.start() e.wait() router.stop()
def startRouter(): if self.identification is not None: setproctitle(self.identification) router = Default(config, size=self.queue_size, frequency=self.frequency, identification=self.identification, graph=self.graph, graph_include_sys=self.graph_include_sys) router.start() e.wait() router.stop()
from wishbone import Actor from wishbone.router import Default from wishbone.module import Null from wishbone.module import LogLevelFilter from wishbone.module import STDOUT from wishbone.module import Header from wishbone.module import TestEvent from wishbone.module import Graphite from wb_output_amqp import AMQP from wb_output_tcp import TCP #Initialize router router = Default(interval=1, rescue=False, uuid=False, throttle=True) #organize metricstream router.registerMetricModule(Null, "null") #router.registerMetricModule(Graphite, "graphite") #router.register(TCP, "graphite_transport", host="graphite-001", port=2013) #router.connect("graphite.outbox", "graphite_transport.inbox") #organize logstream router.registerLogModule(LogLevelFilter, "loglevelfilter", max_level=7) router.register(STDOUT, "stdout_logs") router.connect("loglevelfilter.outbox", "stdout_logs.inbox") #router.register(TestEvent, "testevent", interval=1) router.register(TestEvent, "testevent", interval=0.5) router.register(Header,
Actor.__init__(self, name, setupbasic=False) self.createQueue("outbox", 1000) thread = threading.Thread(target=self.run) thread.setDaemon(True) thread.start() def run(self): while self.loop(): try: self.queuepool.outbox.put({"header": {}, "data": "X"}) except: self.queuepool.outbox.waitUntilPutAllowed() #Initialize router router = Default(interval=1, rescue=False, uuid=False) #Organize log flow router.registerLogModule((Filter, "logformatfilter", 0)) router.register((STDOUT, "stdout", 0)) router.connect("logformatfilter.outbox", "stdout.inbox") #Organize metric flow router.registerMetricModule((Graphite, "graphite", 0)) router.register((TCP, 'graphite_out', 0), host="graphite-001", port=2013, stream=True) router.connect("graphite.outbox", "graphite_out.inbox") #Organize data flow
# from wishbone import Actor from wishbone.router import Default from wishbone.tools import Measure from wishbone.module import Graphite from wishbone.module import Null from wishbone.module import LogFormatFilter from wishbone.module import STDOUT from wb_input_udp import UDP from gevent import sleep, spawn #Initialize router router = Default(interval=1, rescue=False, uuid=False) router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=True) router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((STDOUT, "stdout", 0)) router.register((Null, "null", 0)) router.connect("logformatfilter.outbox", "stdout.inbox") router.connect("graphite.outbox", "null.inbox") #Consume events to STDOUT router.register((UDP, "udp", 0)) router.register((STDOUT, "stdout_events", 0)) router.connect("udp.outbox", "stdout_events.inbox")
# # from wishbone import Actor from wishbone.router import Default from wishbone.tools import Measure from wishbone.module import Graphite from wishbone.module import Null from wishbone.module import LogFormatFilter from wishbone.module import STDOUT from wb_input_tcp import TCP from wb_input_gearman import Gearman #Initialize router router = Default(interval=1, rescue=False, uuid=False) router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=True) router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((STDOUT, "stdout", 0)) router.register((Null, "null", 0)) router.connect("logformatfilter.outbox", "stdout.inbox") router.connect("graphite.outbox", "null.inbox") #Consume events to STDOUT router.register( (Gearman, "gearman", 0), hostlist=["besrvuc-nag02:4730"], queue="perfdata", workers=10,
from wishbone import Actor from wishbone.router import Default from wishbone.module import Null from wishbone.module import LogLevelFilter from wishbone.module import STDOUT from wishbone.module import Header from wishbone.module import TestEvent from wishbone.module import Fanout from wb_output_mqtt import MQTT from gevent import sleep, spawn #Initialize router router = Default(interval=1, rescue=False, uuid=False) #organize eventstream router.registerMetricModule(Null, "null") #organize logstream router.registerLogModule(LogLevelFilter, "loglevelfilter") router.register(STDOUT, "stdout_logs") router.connect("loglevelfilter.outbox", "stdout_logs.inbox") router.register(TestEvent, "testevent", interval=0) router.register(Header, "header", header={"mqtt": {"topic": "my/topic"}}) router.register(MQTT, "mqtt", client_id="blah", host="127.0.0.1") router.connect("testevent.outbox", "header.inbox") router.connect("header.outbox", "mqtt.inbox")
# from wishbone import Actor from wishbone.router import Default from wishbone.tools import Measure from wishbone.module import Graphite from wishbone.module import Null from wishbone.module import LogFormatFilter from wishbone.module import STDOUT from wb_input_udp import UDP from gevent import sleep, spawn # Initialize router router = Default(interval=1, rescue=False, uuid=False) router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=True) router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((STDOUT, "stdout", 0)) router.register((Null, "null", 0)) router.connect("logformatfilter.outbox", "stdout.inbox") router.connect("graphite.outbox", "null.inbox") # Consume events to STDOUT router.register((UDP, "udp", 0)) router.register((STDOUT, "stdout_events", 0)) router.connect("udp.outbox", "stdout_events.inbox") # start
self.createQueue("outbox", max_size) spawn(self.generate) def generate(self): context_switch_loop = self.getContextSwitcher(75, self.loop) while context_switch_loop.do(): try: self.queuepool.outbox.put({"header":{},"data":"X"}) except QueueFull: sleeping = (self.queuepool.outbox.stats()["out_rate"])+0.1 self.logging.info("Oops queue full waiting for %s seconds."%(sleeping)) sleep(sleeping) #Initialize router router = Default(interval=1, rescue=False, uuid=False) #Organize log flow router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=False) router.register((STDOUT, "stdout", 0)) router.connect("logformatfilter.outbox", "stdout.inbox") #Organize metric flow router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((TCP, 'graphite_out', 0), host="graphite-001", port=2013, stream=True ) router.connect("graphite.outbox", "graphite_out.inbox") #Organize data flow router.register((XGenerator, "xgenerator", 0)) router.register((WaitSeconds, "waitseconds", 0), seconds=0.5, max_size=10) router.connect("xgenerator.outbox", "waitseconds.inbox")
# # from wishbone import Actor from wishbone.router import Default from wishbone.tools import Measure from wishbone.module import Graphite from wishbone.module import Null from wishbone.module import LogFormatFilter from wishbone.module import STDOUT from wb_input_tcp import TCP from wb_input_gearman import Gearman #Initialize router router = Default(interval=1, rescue=False, uuid=False) router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=True) router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((STDOUT, "stdout", 0)) router.register((Null, "null", 0)) router.connect("logformatfilter.outbox", "stdout.inbox") router.connect("graphite.outbox", "null.inbox") #Consume events to STDOUT router.register((Gearman, "gearman", 0), hostlist=["besrvuc-nag02:4730"], queue="perfdata", workers=10, secret="Aloh9uibshojeF8oAhyo3eefGu5ohr3iDeek4ehamaM9eisoas6OoveiareQuo0i") router.register((STDOUT, "stdout_events", 0)) router.connect("gearman.outbox", "stdout_events.inbox") #start
class RouterBootstrap(): ''' Setup, configure and a router process. ''' def __init__(self, config, debug=False, queue_size=100, frequency=1, identification=None): self.config = config self.identification = identification self.debug = debug self.router = Default(size=queue_size, frequency=frequency) self.module = Module() def loadModule(self, name): ''' Loads a module using the entrypoint name. ''' return self.module.load(name) def setupModules(self, modules): ''' Loads and initialzes the modules from the bootstrap file. ''' for module in modules: m = self.loadModule(modules[module]["module"]) if "arguments" in modules[module]: self.router.registerModule(m, module, **modules[module]["arguments"]) else: self.router.registerModule(m, module) def setupRoutes(self, table): ''' Connects the modules from the bootstrap file. ''' for route in table: sm, sq, dm, dq = self.__splitRoute(route) self.router.pool.getModule(sm).connect(sq, self.router.pool.getModule(dm), dq) def start(self): ''' Calls the router's start() function. ''' self.setupModules(self.config["modules"]) self.setupRoutes(self.config["routingtable"]) if self.debug: self.__debug() try: syslog = self.loadModule("wishbone.output.syslog") self.router.registerModule(syslog, "syslog", ident=self.identification) self.router.pool.getModule("logs_funnel").connect("outbox", self.router.pool.getModule("syslog"), "inbox") except QueueConnected: pass self.router.start() while self.router.isRunning(): sleep(1) def stop(self): ''' Calls the router's stop() function. ''' self.router.stop() def __debug(self): ''' In debug mode we route all logging to SDOUT. ''' # In debug mode we write our logs to STDOUT log_stdout = self.loadModule("wishbone.output.stdout") log_human = self.loadModule("wishbone.encode.humanlogformat") self.router.registerModule(log_stdout, "log_stdout") self.router.registerModule(log_human, "log_format", ident=self.identification) self.router.pool.getModule("logs_funnel").connect("outbox", self.router.pool.getModule("log_format"), "inbox") self.router.pool.getModule("log_format").connect("outbox", self.router.pool.getModule("log_stdout"), "inbox") def __splitRoute(self, definition): ''' Splits the route definition string into 4 separate string. ''' (source, destination) = definition.split('->') (sm, sq) = source.rstrip().lstrip().split('.') (dm, dq) = destination.rstrip().lstrip().split('.') return sm, sq, dm, dq
self.queuepool.inbox.putUnlock() class Output(Actor): def __init__(self, name, size=1): Actor.__init__(self, name, setupbasic=False) self.createQueue("inbox", size) self.registerConsumer(self.consume, self.queuepool.inbox) def consume(self, event): self.logging.info("Received event.") sleep(5) #Initialize router router = Default(interval=1, rescue=False, uuid=False) #Organize log flow router.registerLogModule(LogLevelFilter, "loglevelfilter") router.register(STDOUT, "stdout") router.connect("loglevelfilter.outbox", "stdout.inbox") #Organize metric flow router.registerMetricModule(Null, "null") #Organize data flow router.register(Input, "input") router.register(Forwarder, "forwarder") router.register(Output, "output") router.connect("input.outbox", "forwarder.inbox")
while self.loop(): try: if looper == 100: looper = 0 sleep() self.queuepool.outbox.put( {"header": {"broker_exchange": "", "broker_key": "test", "broker_tag": "test"}, "data": str(x)} ) x += 1 looper += 1 except: break # Initialize router router = Default(interval=1, rescue=False, uuid=False) router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=False) router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((STDOUT, "stdout", 0)) router.register((Null, "null", 0)) router.connect("logformatfilter.outbox", "stdout.inbox") router.connect("graphite.outbox", "null.inbox") # Feedback loop router.register((Header, "header", 0), header={"broker_exchange": "", "broker_key": "test", "broker_tag": "test"}) router.register((AMQP, "broker", 0), host="sandbox", consume_queue="test") router.connect("broker.inbox", "header.inbox") router.connect("header.outbox", "broker.outbox") # Produce events # router.register((NumberGenerator, "numbergenerator", 0))
def generate(self): context_switch_loop = self.getContextSwitcher(75, self.loop) while context_switch_loop.do(): try: self.queuepool.outbox.put({"header": {}, "data": "X"}) except QueueFull: sleeping = (self.queuepool.outbox.stats()["out_rate"]) + 0.1 self.logging.info("Oops queue full waiting for %s seconds." % (sleeping)) sleep(sleeping) #Initialize router router = Default(interval=1, rescue=False, uuid=False) #Organize log flow router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=False) router.register((STDOUT, "stdout", 0)) router.connect("logformatfilter.outbox", "stdout.inbox") #Organize metric flow router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((TCP, 'graphite_out', 0), host="graphite-001", port=2013, stream=True) router.connect("graphite.outbox", "graphite_out.inbox")
class Output(Actor): def __init__(self, name, size=1000): Actor.__init__(self, name, setupbasic=False) self.createQueue("inbox", size) self.registerConsumer(self.consume, self.queuepool.inbox) def consume(self, event): pass #self.logging.info("Received event.") #sleep(0.005) #Initialize router router = Default(interval=1, rescue=False, uuid=False) #Organize log flow router.registerLogModule(LogLevelFilter, "loglevelfilter", max_level=7) router.register(STDOUT, "stdout") router.connect("loglevelfilter.outbox", "stdout.inbox") #Organize metric flow router.registerMetricModule(Null, "null") # router.registerMetricModule(Graphite, "graphite") # router.register(TCP, "graphite_transport", host="graphite-001", port=2013) # router.connect("graphite.outbox", "graphite_transport.inbox") #Organize data flow router.register(AMQP, "amqp",
from wishbone import Actor from wishbone.router import Default from wishbone.module import Null from wishbone.module import LogLevelFilter from wishbone.module import STDOUT from wishbone.module import Header from wishbone.module import TestEvent from wishbone.module import Graphite from wb_output_amqp import AMQP from wb_output_tcp import TCP #Initialize router router = Default(interval=1, rescue=False, uuid=False, throttle=True) #organize metricstream router.registerMetricModule(Null, "null") #router.registerMetricModule(Graphite, "graphite") #router.register(TCP, "graphite_transport", host="graphite-001", port=2013) #router.connect("graphite.outbox", "graphite_transport.inbox") #organize logstream router.registerLogModule(LogLevelFilter, "loglevelfilter", max_level=7) router.register(STDOUT, "stdout_logs") router.connect("loglevelfilter.outbox", "stdout_logs.inbox") #router.register(TestEvent, "testevent", interval=1) router.register(TestEvent, "testevent", interval=0.5) router.register(Header, "header", key="amqp", header={'broker_exchange':"", 'broker_key':"test", 'broker_tag':"test"})
from wishbone import Actor from wishbone.router import Default from wishbone.tools import Measure from wishbone.module import Graphite from wishbone.module import Null from wishbone.module import LogFormatFilter from wishbone.module import STDOUT from wb_input_namedpipe import NamedPipe from wb_function_json import JSON from gevent import sleep, spawn #Initialize router router = Default(interval=1, rescue=False, uuid=False) router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=True) router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((STDOUT, "stdout", 0)) router.register((Null, "null", 0)) router.connect("logformatfilter.outbox", "stdout.inbox") router.connect("graphite.outbox", "null.inbox") #Consume events to STDOUT router.register((NamedPipe, "namedpipe", 0)) router.register((JSON, "jsonconversion", 0), mode="decode", schema="/tmp/schema.example") router.register((STDOUT, "stdout_events", 0)) router.connect("namedpipe.outbox", "jsonconversion.inbox") router.connect("jsonconversion.outbox", "stdout_events.inbox")
def __init__(self, name): Actor.__init__(self, name, setupbasic=False) self.createQueue("outbox") spawn(self.generate) def generate(self): context_switch_loop = self.getContextSwitcher(100, self.loop) while context_switch_loop.do(): try: self.queuepool.outbox.put({"header": {}, "data": "X"}) except: break #Initialize router router = Default(interval=1, rescue=False, uuid=False) #Organize log flow router.registerLogModule(STDOUT, "stdout") #Organize metric flow router.registerMetricModule(Graphite, "graphite") router.register(TCP, 'graphite_out', host="graphite-001", port=2013) router.connect("graphite.outbox", "graphite_out.inbox") #Organize data flow router.register(XGenerator, "xgenerator") router.register(Null, "null") router.connect("xgenerator.outbox", "null.inbox") #start
from wishbone import Actor from wishbone.router import Default from wishbone.module import Null from wishbone.module import LogLevelFilter from wishbone.module import STDOUT from wishbone.module import Header from wishbone.module import TestEvent from wishbone.module import Fanout from wb_output_mqtt import MQTT from gevent import sleep, spawn # Initialize router router = Default(interval=1, rescue=False, uuid=False) # organize eventstream router.registerMetricModule(Null, "null") # organize logstream router.registerLogModule(LogLevelFilter, "loglevelfilter") router.register(STDOUT, "stdout_logs") router.connect("loglevelfilter.outbox", "stdout_logs.inbox") router.register(TestEvent, "testevent", interval=0) router.register(Header, "header", header={"mqtt": {"topic": "my/topic"}}) router.register(MQTT, "mqtt", client_id="blah", host="127.0.0.1") router.connect("testevent.outbox", "header.inbox") router.connect("header.outbox", "mqtt.inbox")
from wishbone import Actor from wishbone.router import Default from wishbone.tools import Measure from wishbone.module import Graphite from wishbone.module import Null from wishbone.module import LogLevelFilter from wishbone.module import STDOUT from wb_input_dictgenerator import DictGenerator from wb_output_tcp import TCP from gevent import sleep, spawn #Initialize router router = Default(interval=1, rescue=False, uuid=False) #Organize log flow router.registerLogModule(LogLevelFilter, "filter") router.register(STDOUT, "stdout") router.connect("filter.outbox", "stdout.inbox") #Organize metric flow router.registerMetricModule(Graphite, "graphite") router.register(TCP, 'graphite_out', host="graphite-001", port=2013) router.connect("graphite.outbox", "graphite_out.inbox") #Organize event flow router.register(DictGenerator, "dictgenerator", max_elements=10) router.register(STDOUT, "stdout_events") router.register(Null, "null_events")
def __init__(self, config, debug=False, queue_size=100, frequency=1, identification=None): self.config = config self.identification = identification self.debug = debug self.router = Default(size=queue_size, frequency=frequency) self.module = Module()
from wishbone import Actor from wishbone.router import Default from wishbone.tools import Measure from wishbone.module import Graphite from wishbone.module import Null from wishbone.module import LogLevelFilter from wishbone.module import STDOUT from wb_input_dictgenerator import DictGenerator from wb_output_tcp import TCP from gevent import sleep, spawn #Initialize router router = Default(interval=1, rescue=False, uuid=False) #Organize log flow # router.registerLogModule(LogLevelFilter, "filter") # router.register(STDOUT, "stdout") # router.connect("filter.outbox", "stdout.inbox") #Organize metric flow # router.registerMetricModule(Graphite, "graphite") # router.register(TCP, 'graphite_out', host="graphite-001", port=2013) # router.connect("graphite.outbox", "graphite_out.inbox") #Organize event flow router.register(DictGenerator, "dictgenerator", max_elements=10) router.register(STDOUT, "stdout_events") router.connect("dictgenerator.outbox", "stdout_events.inbox")
def run(self): x = 0 looper = 0 while self.loop(): try: if looper == 100: looper = 0 sleep() self.queuepool.outbox.put({"header": {}, "data": str(x)}) x += 1 looper += 1 except: break router = Default(interval=1, rescue=False, uuid=False) router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=False) router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((STDOUT, "stdout", 0)) router.register((NumberGenerator, "numbergenerator", 0)) router.register((Fanout, "fanout", 0), clone=True) router.register((STDOUT, "stdout1", 0), counter=False, complete=False) router.register((STDOUT, "stdout2", 0), counter=True, complete=True) router.register((STDOUT, "stdout3", 0), counter=True, complete=True) #logs & metrics router.connect("logformatfilter.outbox", "stdout.inbox")
def run(self): x = 0 looper = 0 while self.loop(): try: if looper == 100: looper = 0 sleep() self.queuepool.outbox.put({"header": {}, "data": str(x)}) x += 1 looper += 1 except: break router = Default(interval=1, rescue=False, uuid=False) router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=False) router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((STDOUT, "stdout_logs", 0)) router.register((STDOUT, "stdout", 0)) router.register((NumberGenerator, "numbergenerator1", 0)) router.register((NumberGenerator, "numbergenerator2", 0)) router.register((Funnel, "funnel", 0)) #logs & metrics router.connect("logformatfilter.outbox", "stdout_logs.inbox") #events
self.queuepool.outbox.waitUntilPutAllowed() self.queuepool.inbox.putUnlock() class Output(Actor): def __init__(self, name, size=1000): Actor.__init__(self, name, setupbasic=False) self.createQueue("inbox", size) self.registerConsumer(self.consume, self.queuepool.inbox) def consume(self, event): pass #self.logging.info("Received event.") #sleep(0.005) #Initialize router router = Default(interval=1, rescue=False, uuid=False) #Organize log flow router.registerLogModule(LogLevelFilter, "loglevelfilter", max_level=7) router.register(STDOUT, "stdout") router.connect("loglevelfilter.outbox", "stdout.inbox") #Organize metric flow router.registerMetricModule(Null, "null") # router.registerMetricModule(Graphite, "graphite") # router.register(TCP, "graphite_transport", host="graphite-001", port=2013) # router.connect("graphite.outbox", "graphite_transport.inbox") #Organize data flow router.register(AMQP, "amqp", host="localhost", queue="test", prefetch_count=100, no_ack=True) router.register(Forwarder, "forwarder")
from wishbone import Actor from wishbone.router import Default from wishbone.tools import Measure from wishbone.module import Graphite from wishbone.module import Null from wishbone.module import LogLevelFilter from wishbone.module import STDOUT from wb_input_dictgenerator import DictGenerator from wb_output_tcp import TCP from wb_output_mongodb import MongoDB from gevent import sleep, spawn #Initialize router router = Default(interval=1, context_switch=100, rescue=False, uuid=False) #organize log flow router.registerLogModule(LogLevelFilter, "loglevelfilter") router.register(STDOUT, "stdout_logs") router.connect("loglevelfilter.outbox", "stdout_logs.inbox") #organize metric flow router.registerMetricModule(Graphite, "graphite") router.register(TCP, 'graphite_out', host="graphite-001", port=2013, stream=True) router.connect("graphite.outbox", "graphite_out.inbox")
# from wishbone import Actor from wishbone.router import Default from wishbone.module import Null from wishbone.module import LogLevelFilter from wishbone.module import STDOUT from wishbone.module import Header from wishbone.module import TestEvent from wb_output_udp import UDP from gevent import sleep, spawn #Initialize router router = Default(interval=1, rescue=False, uuid=False) #organize eventstream router.registerMetricModule(Null, "null") #organize logstream router.registerLogModule(LogLevelFilter, "loglevelfilter") router.register(STDOUT, "stdout_logs") router.connect("loglevelfilter.outbox", "stdout_logs.inbox") router.register(TestEvent, "testevent") router.register(UDP, "udp", host="localhost") router.connect("testevent.outbox", "udp.inbox") #start
def run(self): x=0 looper=0 while self.loop(): try: if looper == 100: looper=0 sleep() self.queuepool.outbox.put({"header":{},"data":str(x)}) x+=1 looper+=1 except: break router = Default(interval=1, rescue=False, uuid=False) router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=False) router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((STDOUT, "stdout", 0)) router.register((NumberGenerator, "numbergenerator", 0)) router.register((Fanout, "fanout", 0), clone=True) router.register((STDOUT, "stdout1", 0), counter=False, complete=False) router.register((STDOUT, "stdout2", 0), counter=True, complete=True) router.register((STDOUT, "stdout3", 0), counter=True, complete=True) #logs & metrics router.connect("logformatfilter.outbox", "stdout.inbox") #events
self.queuepool.inbox.putLock() self.queuepool.outbox.waitUntilPutAllowed() self.queuepool.inbox.putUnlock() class Output(Actor): def __init__(self, name, size=1): Actor.__init__(self, name, setupbasic=False) self.createQueue("inbox", size) self.registerConsumer(self.consume, self.queuepool.inbox) def consume(self, event): self.logging.info("Received event.") sleep(5) #Initialize router router = Default(interval=1, rescue=False, uuid=False) #Organize log flow router.registerLogModule(LogLevelFilter, "loglevelfilter") router.register(STDOUT, "stdout") router.connect("loglevelfilter.outbox", "stdout.inbox") #Organize metric flow router.registerMetricModule(Null, "null") #Organize data flow router.register(Input, "input") router.register(Forwarder, "forwarder") router.register(Output, "output") router.connect("input.outbox", "forwarder.inbox")
from wishbone import Actor from wishbone.router import Default from wishbone.tools import Measure from wishbone.module import Graphite from wishbone.module import Null from wishbone.module import LogLevelFilter from wishbone.module import STDOUT from wb_input_dictgenerator import DictGenerator from wb_output_tcp import TCP from wb_output_mongodb import MongoDB from gevent import sleep, spawn #Initialize router router = Default(interval=1, context_switch=100, rescue=False, uuid=False) #organize log flow router.registerLogModule(LogLevelFilter, "loglevelfilter") router.register(STDOUT, "stdout_logs") router.connect("loglevelfilter.outbox", "stdout_logs.inbox") #organize metric flow router.registerMetricModule(Graphite, "graphite") router.register(TCP, 'graphite_out', host="graphite-001", port=2013, stream=True ) router.connect("graphite.outbox", "graphite_out.inbox") #organize event flow router.register(DictGenerator, "dictgenerator", max_elements=10, sleep=1) router.register(MongoDB, "mongodb", host="sandbox", capped=True, drop_db=False) router.connect("dictgenerator.outbox", "mongodb.inbox")
def run(self): x=0 looper=0 while self.loop(): try: if looper == 100: looper=0 sleep() self.queuepool.outbox.put({"header":{},"data":str(x)}) x+=1 looper+=1 except: break router = Default(interval=1, rescue=False, uuid=False) router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=False) router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((STDOUT, "stdout_logs", 0)) router.register((STDOUT, "stdout", 0)) router.register((NumberGenerator, "numbergenerator1", 0)) router.register((NumberGenerator, "numbergenerator2", 0)) router.register((Funnel, "funnel", 0)) #logs & metrics router.connect("logformatfilter.outbox", "stdout_logs.inbox") #events router.connect("numbergenerator1.outbox", "funnel.one") router.connect("numbergenerator2.outbox", "funnel.two")
class XGenerator(Actor): def __init__(self, name): Actor.__init__(self, name, setupbasic=False) self.createQueue("outbox") spawn(self.generate) def generate(self): context_switch_loop = self.getContextSwitcher(100, self.loop) while context_switch_loop.do(): try: self.queuepool.outbox.put({"header":{},"data":"X"}) except: break #Initialize router router = Default(interval=1, rescue=False, uuid=False) #Organize log flow router.registerLogModule(STDOUT, "stdout") #Organize metric flow router.registerMetricModule(Graphite, "graphite") router.register(TCP, 'graphite_out', host="graphite-001", port=2013) router.connect("graphite.outbox", "graphite_out.inbox") #Organize data flow router.register(XGenerator, "xgenerator") router.register(Null, "null") router.connect("xgenerator.outbox", "null.inbox") #start
Actor.__init__(self, name) self.createQueue("inbox") self.registerConsumer(self.consume, self.queuepool.inbox) def consume(self, event): self.logging.info("Received event.") sleep(0.5) # gevent_profiler.set_stats_output('my-stats.txt') # gevent_profiler.set_summary_output('my-summary.txt') # gevent_profiler.set_trace_output('my-trace.txt') # gevent_profiler.attach() #Initialize router router = Default(interval=1, rescue=False, uuid=False) router.registerLogModule(STDOUT, "logs_out") router.registerMetricModule(STDOUT, "metrics_out") router.register(Input, "input") router.register(Output, "output") router.connect("input.outbox", "output.inbox") #start router.start() router.block() # gevent_profiler.detach()
self.queuepool.outbox.put({ "header": { 'broker_exchange': "", 'broker_key': "test", 'broker_tag': "test" }, "data": str(x) }) x += 1 looper += 1 except: break #Initialize router router = Default(interval=1, rescue=False, uuid=False) router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=False) router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((STDOUT, "stdout", 0)) router.register((Null, "null", 0)) router.connect("logformatfilter.outbox", "stdout.inbox") router.connect("graphite.outbox", "null.inbox") #Feedback loop router.register((Header, "header", 0), header={ 'broker_exchange': "", 'broker_key': "test", 'broker_tag': "test"
from wishbone import Actor from wishbone.router import Default from wishbone.tools import Measure from wishbone.module import Graphite from wishbone.module import Null from wishbone.module import LogFormatFilter from wishbone.module import STDOUT from wb_input_namedpipe import NamedPipe from wb_function_json import JSON from gevent import sleep, spawn #Initialize router router = Default(interval=1, rescue=False, uuid=False) router.registerLogModule((LogFormatFilter, "logformatfilter", 0), "inbox", debug=True) router.registerMetricModule((Graphite, "graphite", 0), "inbox") router.register((STDOUT, "stdout", 0)) router.register((Null, "null", 0)) router.connect("logformatfilter.outbox", "stdout.inbox") router.connect("graphite.outbox", "null.inbox") #Consume events to STDOUT router.register((NamedPipe, "namedpipe", 0)) router.register((JSON, "jsonconversion", 0), mode="decode", schema="/tmp/schema.example") router.register((STDOUT, "stdout_events", 0))