コード例 #1
0
async def test_round_robin_group_router_routees_can_be_added():
    router, routee1, routee2, routee3 = create_router_with3_routees()
    routee4 = context.spawn(my_actor_props)
    await context.send(router, AddRoutee(routee4))

    routees = await context.request_async(router, GetRoutees(), timeout)
    assert routee1 in routees.pids
    assert routee2 in routees.pids
    assert routee3 in routees.pids
    assert routee4 in routees.pids
コード例 #2
0
async def test_consistent_hash_group_router_routees_can_be_added():
    router, routee1, routee2, routee3 = create_broadcast_group_router_with3_routees(
    )
    routee4 = context.spawn(my_actor_props)
    await context.send(router, AddRoutee(routee4))

    routees = await context.request_future(router, GetRoutees(), timeout)

    assert routee1 in routees.pids
    assert routee2 in routees.pids
    assert routee3 in routees.pids
    assert routee4 in routees.pids
コード例 #3
0
async def test_consistent_hash_group_router_message_with_same_hash_always_goes_to_same_routee_even_when_new_routee_added(
):
    router, routee1, routee2, routee3 = create_broadcast_group_router_with3_routees(
    )

    await context.send(router, Message('message1'))
    routee4 = context.spawn(my_actor_props)
    await context.send(router, AddRoutee(routee4))
    await context.send(router, Message('message1'))

    assert await context.request_future(routee1, 'received?', timeout) == 2
    assert await context.request_future(routee2, 'received?', timeout) == 0
    assert await context.request_future(routee3, 'received?', timeout) == 0
コード例 #4
0
async def test_random_group_router_newly_added_routees_receive_messages():
    router, routee1, routee2, routee3 = create_router_with3_routees()

    routee4 = context.spawn(my_actor_props)
    await context.send(router, AddRoutee(routee4))

    await context.send(router, '1')
    await context.send(router, '2')
    await context.send(router, '3')
    await context.send(router, '4')

    assert await context.request_future(routee1, 'received?', timeout) == '4'
    assert await context.request_future(routee2, 'received?', timeout) is None
    assert await context.request_future(routee3, 'received?', timeout) == '1'
    assert await context.request_future(routee4, 'received?', timeout) is None
コード例 #5
0
async def test_broadcast_group_router_added_routees_receive_messages():
    router, routee1, routee2, routee3 = create_broadcast_group_router_with3_routees(
    )
    routee4 = context.spawn(my_actor_props)

    await context.send(router, AddRoutee(routee4))
    await context.send(router, 'a message')

    assert await context.request_future(routee1, 'received?',
                                        timeout) == 'a message'
    assert await context.request_future(routee2, 'received?',
                                        timeout) == 'a message'
    assert await context.request_future(routee3, 'received?',
                                        timeout) == 'a message'
    assert await context.request_future(routee4, 'received?',
                                        timeout) == 'a message'