本文整理匯總了Python中wishbone.event.Event.setData方法的典型用法代碼示例。如果您正苦於以下問題:Python Event.setData方法的具體用法?Python Event.setData怎麽用?Python Event.setData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wishbone.event.Event
的用法示例。
在下文中一共展示了Event.setData方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_module_funnel
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_module_funnel():
actor_config = ActorConfig('funnel', 100, 1, {})
funnel = Funnel(actor_config)
funnel.pool.queue.outbox.disableFallThrough()
funnel.pool.createQueue("one")
funnel.pool.queue.one.disableFallThrough()
funnel.pool.createQueue("two")
funnel.pool.queue.two.disableFallThrough()
funnel.start()
event_one = Event("test")
event_one.setData("one")
event_two = Event("test")
event_two.setData("two")
funnel.pool.queue.one.put(event_one)
funnel.pool.queue.two.put(event_two)
assert getter(funnel.pool.queue.outbox).raw()["test"]["data"] in ["one", "two"]
assert getter(funnel.pool.queue.outbox).raw()["test"]["data"] in ["one", "two"]
funnel.stop()
示例2: test_module_loglevelfilter
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_module_loglevelfilter():
actor_config = ActorConfig('loglevelfilter', 100, 1, {})
loglevelfilter = LogLevelFilter(actor_config)
loglevelfilter.pool.queue.inbox.disableFallThrough()
loglevelfilter.pool.queue.outbox.disableFallThrough()
loglevelfilter.start()
e_one = Event('test')
e_one.setData((7, 1367682301.430527, 3342, 'Router', 'Received SIGINT. Shutting down.'))
e_two = Event('test')
e_two.setData((1, 1367682301.430527, 3342, 'Router', 'Received SIGINT. Shutting down.'))
loglevelfilter.pool.queue.inbox.put(e_one)
loglevelfilter.pool.queue.inbox.put(e_two)
one=getter(loglevelfilter.pool.queue.outbox)
assert one.data == (1, 1367682301.430527, 3342, 'Router', 'Received SIGINT. Shutting down.')
try:
two=getter(loglevelfilter.pool.queue.outbox)
except Exception:
assert True
else:
assert False
示例3: test_module_jsonvalidate
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_module_jsonvalidate():
actor_config = ActorConfig('jsonvalidate', 100, 1, {})
with open("/tmp/jsonvalidate.jsonschema", "w") as j:
j.write('{"type": "object", "properties": {"one": { "type": "integer"}}}')
jsonvalidate = JSONValidate(actor_config, "/tmp/jsonvalidate.jsonschema")
jsonvalidate.pool.queue.inbox.disableFallThrough()
jsonvalidate.pool.queue.outbox.disableFallThrough()
jsonvalidate.pool.queue.failed.disableFallThrough()
jsonvalidate.start()
valid = Event('valid')
valid.setData({"one": 1})
invalid = Event('invalid')
invalid.setData({"one": "one"})
jsonvalidate.pool.queue.inbox.put(valid)
valid_event = getter(jsonvalidate.pool.queue.outbox)
jsonvalidate.pool.queue.inbox.put(invalid)
invalid_event = getter(jsonvalidate.pool.queue.failed)
os.remove("/tmp/jsonvalidate.jsonschema")
assert valid_event.data == {"one": 1}
assert invalid_event.data == {"one": "one"}
示例4: test_module_fanout
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_module_fanout():
actor_config = ActorConfig('fanout', 100, 1, {})
fanout = Fanout(actor_config, deep_copy=True)
fanout.pool.queue.inbox.disableFallThrough()
fanout.pool.createQueue("one")
fanout.pool.queue.one.disableFallThrough()
fanout.pool.createQueue("two")
fanout.pool.queue.two.disableFallThrough()
fanout.start()
e = Event('test')
e.setData("hello")
fanout.pool.queue.inbox.put(e)
one = getter(fanout.pool.queue.one)
two = getter(fanout.pool.queue.two)
fanout.stop()
assert one.raw()["test"]["data"] == "hello"
assert two.raw()["test"]["data"] == "hello"
assert id(one) != id(two)
示例5: test_module_roundrobin
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_module_roundrobin():
actor_config = ActorConfig('roundrobin', 100, 1, {})
roundrobin = RoundRobin(actor_config)
roundrobin.pool.queue.inbox.disableFallThrough()
roundrobin.pool.createQueue("one")
roundrobin.pool.queue.one.disableFallThrough()
roundrobin.pool.createQueue("two")
roundrobin.pool.queue.two.disableFallThrough()
roundrobin.start()
event_one = Event("test")
event_one.setData("one")
event_two = Event("test")
event_two.setData("two")
roundrobin.pool.queue.inbox.put(event_one)
roundrobin.pool.queue.inbox.put(event_two)
assert getter(roundrobin.pool.queue.one).raw()["test"]["data"] in ["one", "two"]
assert getter(roundrobin.pool.queue.two).raw()["test"]["data"] in ["one", "two"]
roundrobin.stop()
示例6: test_file_load
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_file_load():
import os
import yaml
import shutil
os.mkdir('/tmp/wishbone_tests')
actor_config = ActorConfig('match', 100, 1, {})
match = Match(actor_config, location="/tmp/wishbone_tests")
match.pool.createQueue("file")
match.pool.queue.file.disableFallThrough()
match.pool.queue.inbox.disableFallThrough()
#Test 1
rule_1 = {
"condition": [
{"file": "re:.*?one.*"}
],
"queue": [
{"file": {}}
]
}
with open('/tmp/wishbone_tests/one.yaml', 'w') as one:
one.write(yaml.dump(rule_1, default_flow_style=False))
match.start()
sleep(1)
e = Event("test")
e.setData({"file": "zero one two"})
match.pool.queue.inbox.put(e)
assert getter(match.pool.queue.file).data["file"] == "zero one two"
#Test 2
rule_2 = {
"condition": [
{"file": "re:.*?two.*"}
],
"queue": [
{"file": {}}
]
}
with open('/tmp/wishbone_tests/two.yaml', 'w') as one:
one.write(yaml.dump(rule_2, default_flow_style=False))
sleep(1)
e = Event("test")
e.setData({"file": "one two three"})
match.pool.queue.inbox.put(e)
assert getter(match.pool.queue.file).data["file"] == "one two three"
shutil.rmtree('/tmp/wishbone_tests')
示例7: test_module_humanlogformat
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_module_humanlogformat():
actor_config = ActorConfig('humanlogformat', 100, 1, {})
humanlogformat = HumanLogFormat(actor_config, colorize=False, ident='setup.py')
humanlogformat.pool.queue.inbox.disableFallThrough()
humanlogformat.pool.queue.outbox.disableFallThrough()
humanlogformat.start()
e = Event('test')
e.setData(Log(1367682301.430527, 6, 3342, 'Router', 'Received SIGINT. Shutting down.'))
humanlogformat.pool.queue.inbox.put(e)
one = getter(humanlogformat.pool.queue.outbox)
assert one.data == "2013-05-04T17:45:01 setup.py[3342]: informational Router: Received SIGINT. Shutting down."
示例8: test_module_msgpackencode
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_module_msgpackencode():
actor_config = ActorConfig("msgpackencode", 100, 1, {})
msgpackencode = MSGPackEncode(actor_config)
msgpackencode.pool.queue.inbox.disableFallThrough()
msgpackencode.pool.queue.outbox.disableFallThrough()
msgpackencode.start()
e = Event("test")
e.setData([1, 2, 3])
msgpackencode.pool.queue.inbox.put(e)
one = getter(msgpackencode.pool.queue.outbox)
assert one.data == "\x93\x01\x02\x03"
示例9: test_module_jsonencode
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_module_jsonencode():
actor_config = ActorConfig('jsonencode', 100, 1, {})
jsonencode = JSONEncode(actor_config)
jsonencode.pool.queue.inbox.disableFallThrough()
jsonencode.pool.queue.outbox.disableFallThrough()
jsonencode.start()
e = Event('test')
e.setData(["one", "two", "three"])
jsonencode.pool.queue.inbox.put(e)
one = getter(jsonencode.pool.queue.outbox)
assert one.data == '["one", "two", "three"]'
示例10: test_module_header
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_module_header():
actor_config = ActorConfig('header', 100, 1, {})
header = Header(actor_config, header={"greeting": "hello"})
header.pool.queue.inbox.disableFallThrough()
header.pool.queue.outbox.disableFallThrough()
header.start()
e = Event('test')
e.setData('hello')
header.pool.queue.inbox.put(e)
one = getter(header.pool.queue.outbox)
assert one.getHeaderValue("header", "greeting") == "hello"
示例11: test_module_msgpackdecode
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_module_msgpackdecode():
actor_config = ActorConfig('msgpackdecode', 100, 1, {})
msgpackdecode = MSGPackDecode(actor_config)
msgpackdecode.pool.queue.inbox.disableFallThrough()
msgpackdecode.pool.queue.outbox.disableFallThrough()
msgpackdecode.start()
e = Event('test')
e.setData('\x93\x01\x02\x03')
msgpackdecode.pool.queue.inbox.put(e)
one = getter(msgpackdecode.pool.queue.outbox)
assert one.data == [1, 2, 3]
示例12: test_regex
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_regex():
rule = {"regex": {
"condition": [
{"regex": "re:.*?two.*"}
],
"queue": [
{"regex": {}}
]
}}
actor = generate_actor(rule)
e = Event("test")
e.setData({"regex": "one two three"})
actor.pool.queue.inbox.put(e)
assert getter(actor.pool.queue.regex).data["regex"] == "one two three"
示例13: test_equal_to
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_equal_to():
rule = {"equal": {
"condition": [
{"equal": "=:100"}
],
"queue": [
{"equal": {}}
]
}}
actor = generate_actor(rule)
one = Event("test")
one.setData({"equal": "100"})
actor.pool.queue.inbox.put(one)
assert int(getter(actor.pool.queue.equal).data["equal"]) == 100
示例14: test_smaller_than
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_smaller_than():
rule = {"smaller": {
"condition": [
{"smaller": "<:100"}
],
"queue": [
{"smaller": {}}
]
}}
actor = generate_actor(rule)
one = Event("test")
one.setData({"smaller": "99"})
actor.pool.queue.inbox.put(one)
assert int(getter(actor.pool.queue.smaller).data["smaller"]) < 100
示例15: test_bigger_than
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import setData [as 別名]
def test_bigger_than():
rule = {"bigger": {
"condition": [
{"bigger": ">:10"}
],
"queue": [
{"bigger": {}}
]
}}
actor = generate_actor(rule)
e = Event("test")
e.setData({"bigger": "100"})
actor.pool.queue.inbox.put(e)
assert getter(actor.pool.queue.bigger).data["bigger"] == "100"