Beispiel #1
0
def repl_refresh_behaviors():
    every_15_min = relativedelta(minutes=15)
    every_6_hours = relativedelta(hours=6)
    every_1_day = relativedelta(days=1)
    every_1_week = relativedelta(weeks=1)
    every_1_month = relativedelta(months=1)
    every_1_year = relativedelta(years=1)
    first_of_year = datetime(2015, 1, 1, tzinfo=pytz.utc)
    first_of_month = datetime(2015, 2, 1, tzinfo=pytz.utc)
    second_of_month = datetime(2015, 2, 2, tzinfo=pytz.utc)
    end_of_year = datetime(2015, 12, 31, tzinfo=pytz.utc)
    end_of_month = datetime(2015, 2, 28, tzinfo=pytz.utc)
    refresh_behaviors = [
        # One Time Refresh
        OneTimeRefresh(first_of_year),
        OneTimeRefresh(first_of_month),
        OneTimeRefresh(end_of_month),
        OneTimeRefresh(end_of_year),
        # Recurring Refresh requires an "End" and an "interval"
        RecurringRefresh(first_of_year, end_of_year, every_1_year),
        RecurringRefresh(first_of_year, end_of_year, every_1_month),
        RecurringRefresh(first_of_year, end_of_month, every_1_month),
        RecurringRefresh(first_of_month, end_of_month, every_1_month),
        RecurringRefresh(first_of_month, end_of_month, every_1_week),
        RecurringRefresh(first_of_month, second_of_month, every_6_hours),
        RecurringRefresh(first_of_month, second_of_month, every_15_min),
        # Recurring refresh could be a "One Time" Refresh
        RecurringRefresh(first_of_year, first_of_year, None),
        # Recurring refresh could run until 'now' or 'future-forever'
        RecurringRefresh(first_of_year, None, every_1_day),
    ]
    return refresh_behaviors
Beispiel #2
0
def repl_test_strategy():
    """
    Create an AllocationStrategy by instantiating
    Refresh, Counting, (and Rules?) behaviors
    """
    first_of_feb = datetime(2015, 2, 1, tzinfo=pytz.utc)
    first_of_march = datetime(2015, 3, 1, tzinfo=pytz.utc)
    every_1_month = relativedelta(months=1)

    refresh_behavior = RecurringRefresh(first_of_feb, first_of_march,
                                        every_1_month)
    counting_behavior = FixedWindow(first_of_feb, first_of_march)
    strategy = PythonAllocationStrategy(counting_behavior, [refresh_behavior])
    return strategy