Пример #1
0
def get_log_dispatcher(log, fields):
    """
    Get dispatcher containing performers for logging intents that
    use given logger and are bound with given fields
    """
    return TypeDispatcher({
        BoundFields: partial(perform_logging, log, fields, bound_log),
        Log: partial(perform_logging, log, fields, log_msg),
        LogErr: partial(perform_logging, log, fields, log_err),
        GetFields: sync_performer(lambda d, i: fields),
    })
Пример #2
0
def dispatcher():
    prefetch_dispatcher = TypeDispatcher({
        TryPrefetch:
        try_prefetch_performer,
        CalculateSha256Sum:
        sync_performer(lambda _, intent: calculate_sha256_sum(intent)),
        GetListRemote:
        get_list_remote_performer,
        AbortWithErrorMessage:
        abort_with_error_message_performer,
    })
    return ComposedDispatcher([base_dispatcher, prefetch_dispatcher])
Пример #3
0
 def dispatch_2(intent):
     if intent == 2:
         return sync_performer(lambda d, i: "yay done")