def test_multicast_dsl(self):
     builder = DslPipelineBuilder()
     builder.source(Source1).to(To1).multicast({})\
         .pipeline().to(To1).to(To1).end_pipeline()\
         .pipeline().to(To1).to(To1).end_pipeline()\
         .end_multicast().to(To1)
     self.assertIsNotNone(builder._builder_stack[-1])
 def test_simple_pipeline(self):
     plumber = Plumber()
     builder1 = DslPipelineBuilder()
     pipeline1 = builder1.source(Timer, {"period": 1.0}).process(insert_seq_number).resequencer({"key_extractor": get_key, "count": 5, "reverse": True}).process(lambda ex: print(ex.in_msg.headers["seq_num"]))
     plumber.add_pipeline(pipeline1)
     plumber.start()
     time.sleep(12)
     plumber.stop()
Example #3
0
 def test_simple_pipeline(self):
     plumber = Plumber()
     builder1 = DslPipelineBuilder()
     pipeline1 = builder1.source(Timer, {"period": 1.0}).filter(Filter()).process(lambda ex: print(ex.in_msg.body))
     plumber.add_pipeline(pipeline1)
     plumber.start()
     time.sleep(10)
     plumber.stop()
Example #4
0
 def test_log(self):
     plumber = Plumber()
     builder = DslPipelineBuilder()
     pipeline = builder.source(Timer, {"period": 1.0}).to(Log, {"name": "test"})
     plumber.add_pipeline(pipeline)
     plumber.start()
     time.sleep(1)
     plumber.stop()
 def test_simple_pipeline(self):
     plumber = Plumber()
     builder1 = DslPipelineBuilder()
     pipeline1 = builder1.source(Timer, {"period": 1.0}).aggregate({"method": aggregate, "count": 5, "timeout": 2}).process(lambda ex: print(ex.in_msg.body))
     plumber.add_pipeline(pipeline1)
     plumber.start()
     time.sleep(12)
     plumber.stop()
 def test_simple_pipeline(self):
     builder = DslPipelineBuilder()
     pipeline = builder.source(Timer, {
         "period": 2.0
     }).to(MessageModifier).process(
         lambda ex: print(ex.in_msg.body)).build()
     pipeline.start()
     time.sleep(10)
     pipeline.stop()
Example #7
0
 def test_simple_pipeline(self):
     plumber = Plumber()
     builder1 = DslPipelineBuilder()
     pipeline1 = builder1.source(Timer, {
         "period": 1.0
     }).filter(Filter()).process(lambda ex: print(ex.in_msg.body))
     plumber.add_pipeline(pipeline1)
     plumber.start()
     time.sleep(10)
     plumber.stop()
Example #8
0
 def test_log(self):
     plumber = Plumber()
     builder = DslPipelineBuilder()
     pipeline = builder.source(Timer, {
         "period": 1.0
     }).to(Log, {"name": "test"})
     plumber.add_pipeline(pipeline)
     plumber.start()
     time.sleep(1)
     plumber.stop()
 def test_simple_pipeline(self):
     plumber = Plumber()
     builder1 = DslPipelineBuilder()
     pipeline1 = builder1.source(Timer, {"period": 1.0}).multicast({"aggregate_method": aggregate}) \
         .pipeline().process(lambda ex: print(ex.in_msg.body + " P11")).process(to_upper).process(lambda ex: print(ex.in_msg.body + " P12")).end_pipeline() \
         .pipeline().process(lambda ex: print(ex.in_msg.body + " P21")).end_pipeline() \
         .end_multicast().process(lambda ex: print(ex.in_msg.body + " Last"))
     plumber.add_pipeline(pipeline1)
     plumber.start()
     time.sleep(10)
     plumber.stop()
Example #10
0
 def test_simple_pipeline(self):
     plumber = Plumber()
     builder1 = DslPipelineBuilder()
     pipeline1 = builder1.source(Timer, {"period": 1.0}).multicast({"aggregate_method": aggregate}) \
         .pipeline().process(lambda ex: print(ex.in_msg.body + " P11")).process(to_upper).process(lambda ex: print(ex.in_msg.body + " P12")).end_pipeline() \
         .pipeline().process(lambda ex: print(ex.in_msg.body + " P21")).end_pipeline() \
         .end_multicast().process(lambda ex: print(ex.in_msg.body + " Last"))
     plumber.add_pipeline(pipeline1)
     plumber.start()
     time.sleep(10)
     plumber.stop()
Example #11
0
 def test_simple_pipeline(self):
     plumber = Plumber()
     builder1 = DslPipelineBuilder()
     builder2 = DslPipelineBuilder()
     pipeline1 = builder1.source(Timer, {"period": 1.0}).to(MessageModifier).process(lambda ex: print(ex.in_msg.body + " Pipeline1"))
     pipeline2 = builder2.source(Timer, {"period": 2.0}).to(MessageModifier).process(lambda ex: print(ex.in_msg.body + " Pipeline2"))
     plumber.add_pipeline(pipeline1)
     plumber.add_pipeline(pipeline2)
     plumber.start()
     time.sleep(10)
     plumber.stop()
Example #12
0
 def test_wiretap(self):
     plumber = Plumber()
     builder = DslPipelineBuilder()
     pipeline = builder.source(Timer, {
         "period": 1.0
     }).wiretap((Log, {
         "name": "wiretap"
     })).to(Log, {"name": "actual"})
     plumber.add_pipeline(pipeline)
     plumber.start()
     time.sleep(1)
     plumber.stop()
Example #13
0
 def test_simple_pipeline(self):
     plumber = Plumber()
     builder1 = DslPipelineBuilder()
     pipeline1 = builder1.source(Timer, {"period": 1.0}).content_based_router() \
         .when(lambda ex: int(ex.in_msg.body.split()[-1]) % 3 == 0).pipeline().process(lambda ex: print(ex.in_msg.body + " %0")).end_pipeline() \
         .when(lambda ex: int(ex.in_msg.body.split()[-1]) % 3 == 1).pipeline().process(lambda ex: print(ex.in_msg.body + " %1")).end_pipeline() \
         .otherwise().pipeline().process(lambda ex: print(ex.in_msg.body + " Otherwise")).end_pipeline() \
         .end_content_based_router().process(lambda ex: print(ex.in_msg.body + " Last"))
     plumber.add_pipeline(pipeline1)
     plumber.start()
     time.sleep(10)
     plumber.stop()
 def test_simple_pipeline(self):
     plumber = Plumber()
     builder1 = DslPipelineBuilder()
     pipeline1 = builder1.source(Timer, {"period": 1.0}).content_based_router() \
         .when(lambda ex: int(ex.in_msg.body.split()[-1]) % 3 == 0).pipeline().process(lambda ex: print(ex.in_msg.body + " %0")).end_pipeline() \
         .when(lambda ex: int(ex.in_msg.body.split()[-1]) % 3 == 1).pipeline().process(lambda ex: print(ex.in_msg.body + " %1")).end_pipeline() \
         .otherwise().pipeline().process(lambda ex: print(ex.in_msg.body + " Otherwise")).end_pipeline() \
         .end_content_based_router().process(lambda ex: print(ex.in_msg.body + " Last"))
     plumber.add_pipeline(pipeline1)
     plumber.start()
     time.sleep(10)
     plumber.stop()
Example #15
0
 def test_simple_pipeline(self):
     plumber = Plumber()
     builder1 = DslPipelineBuilder()
     pipeline1 = builder1.source(Timer, {
         "period": 1.0
     }).aggregate({
         "method": aggregate,
         "count": 5,
         "timeout": 2
     }).process(lambda ex: print(ex.in_msg.body))
     plumber.add_pipeline(pipeline1)
     plumber.start()
     time.sleep(12)
     plumber.stop()
Example #16
0
 def test_simple_pipeline(self):
     plumber = Plumber()
     builder1 = DslPipelineBuilder()
     pipeline1 = builder1.source(Timer, {
         "period": 1.0
     }).process(insert_seq_number).resequencer({
         "key_extractor": get_key,
         "count": 5,
         "reverse": True
     }).process(lambda ex: print(ex.in_msg.headers["seq_num"]))
     plumber.add_pipeline(pipeline1)
     plumber.start()
     time.sleep(12)
     plumber.stop()
Example #17
0
 def test_simple_pipeline(self):
     plumber = Plumber()
     builder1 = DslPipelineBuilder()
     builder2 = DslPipelineBuilder()
     pipeline1 = builder1.source(Timer, {
         "period": 1.0
     }).to(MessageModifier).process(
         lambda ex: print(ex.in_msg.body + " Pipeline1"))
     pipeline2 = builder2.source(Timer, {
         "period": 2.0
     }).to(MessageModifier).process(
         lambda ex: print(ex.in_msg.body + " Pipeline2"))
     plumber.add_pipeline(pipeline1)
     plumber.add_pipeline(pipeline2)
     plumber.start()
     time.sleep(10)
     plumber.stop()
 def test_only_one_source(self):
     builder = DslPipelineBuilder()
     with self.assertRaises(AssertionError):
         builder.source(To1).source(To1)
 def test_simple_pipeline(self):
     builder = DslPipelineBuilder()
     builder.source(Source1).to(To1).to(To2)
     self.assertEqual(builder.source_class, Source1)
 def test_simple_pipeline(self):
     builder = DslPipelineBuilder()
     pipeline = builder.source(Timer, {"period": 2.0}).to(MessageModifier).process(lambda ex: print(ex.in_msg.body)).build()
     pipeline.start()
     time.sleep(10)
     pipeline.stop()
 def test_process_block(self):
     builder = DslPipelineBuilder()
     builder.source(Source1).to(To1).to(To2).process(lambda x: print(x))
     self.assertEqual(builder.source_class, Source1)
     self.assertTrue(inspect.isclass(builder.to_list[2][0]))
 def test_build_pipeline(self):
     builder = DslPipelineBuilder()
     pipeline = builder.source(Source1).to(To1).to(To2).build()
     self.assertIsNotNone(pipeline.source.chain)