Ejemplo n.º 1
0
def generator_function_call_entity(context):
    outputs = []
    entityId = df.EntityId("Counter", "myCounter")
    x = yield context.call_entity(entityId, "add", 3)
    
    outputs.append(x)
    return outputs
Ejemplo n.º 2
0
def test_call_entity_sent():
    context_builder = ContextBuilder('test_simple_function')

    entityId = df.EntityId("Counter", "myCounter")
    result = get_orchestration_state_result(
        context_builder, generator_function_call_entity)

    expected_state = base_expected_state()
    add_call_entity_action(expected_state, entityId, "add", 3)
    expected = expected_state.to_json()

    #assert_valid_schema(result)
    assert_orchestration_state_equals(expected, result)
Ejemplo n.º 3
0
def orchestrator_function(context: df.DurableOrchestrationContext):
    logging.info(f"Executing orchestrator function version 1.1")
    datetimeEntityId = df.EntityId("SoarDatetimeEntity", "latestDatetime")
    stored_datetime = yield context.call_entity(datetimeEntityId, "get")
    logging.info(f"retrieved stored datetime: {stored_datetime}")

    current_datetime = datetime.datetime.utcnow().strftime(
        "%Y-%m-%dT%H:%M:%SZ")
    asyncio.run(
        transfer_abnormal_data_to_sentinel(stored_datetime, current_datetime))

    context.signal_entity(datetimeEntityId, "set", current_datetime)
    logging.info(f"set last_datetime to {current_datetime}")
Ejemplo n.º 4
0
def orchestrator_function(context: df.DurableOrchestrationContext):
    """This function provides the a simple implementation of an orchestrator
    that signals and then calls a counter Durable Entity.

    Parameters
    ----------
    context: DurableOrchestrationContext
        This context has the past history and the durable orchestration API

    Returns
    -------
    state
        The state after applying the operation on the Durable Entity
    """
    entityId = df.EntityId("Counter", "myCounter")
    context.signal_entity(entityId, "add", 3)
    state = yield context.call_entity(entityId, "get")
    return state
Ejemplo n.º 5
0
def test_call_entity_raised():
    entityId = df.EntityId("Counter", "myCounter")
    context_builder = ContextBuilder('test_simple_function')
    add_call_entity_completed_events(context_builder, "add", df.EntityId.get_scheduler_id(entityId), 3)

    result = get_orchestration_state_result(
        context_builder, generator_function_call_entity)

    expected_state = base_expected_state(
        [3]
    )

    add_call_entity_action(expected_state, entityId, "add", 3)
    expected_state._is_done = True
    expected = expected_state.to_json()

    #assert_valid_schema(result)

    assert_orchestration_state_equals(expected, result)