Skip to content

Conversation

ivywei0125
Copy link
Contributor

@ivywei0125 ivywei0125 commented May 9, 2024

Add "Recurrence" parameter for TimeWindowFilter using Outlook-style schema:
https://learn.microsoft.com/en-us/graph/outlook-schedule-recurring-events#using-patterns-and-ranges-to-create-recurring-events

Example:

feature-management:
  feature-flags:
    feature-v:
      enabled-for:
        -
         name: TimeWindowFilter
          parameters:
            start: "Fri, 22 Mar 2024 20:00:00 GMT",
            end: "Mon, 01 July 2024 00:00:00 GMT",
            recurrence:
              pattern:
                type: "Daily",
                interval: 1
              range:
                type: "NoEnd"

The main logic of how to check whether current time is within any recurring time window:
Find the previous occurrence of the recurring time window, let's call it prevOccurrenceStart
Check whether the current time: time is within the time window: prevOccurrenceStart ~ prevOccurrenceStart + End - Start

@ivywei0125 ivywei0125 self-assigned this May 9, 2024
@ivywei0125 ivywei0125 changed the title Yuwe/recurring time window filter App Configuration: recurring time window filter May 9, 2024
@github-actions github-actions bot added the azure-spring All azure-spring related issues label May 9, 2024
@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

com.azure.spring:spring-cloud-azure-feature-management

@ivywei0125 ivywei0125 requested a review from rujche as a code owner June 17, 2024 03:30
feature-v:
enabled-for:
-
name: TimeWindowFilter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change all of these TimeWindowFilter filters to Microsoft.TimeWindow, that is the name when creating through the portal.

@ivywei0125 ivywei0125 merged commit 5c5c7c1 into Azure:feature/spring-boot-3 Jun 28, 2024
@ivywei0125 ivywei0125 deleted the yuwe/recurring-time-window-filter branch June 28, 2024 03:25
Netyyyy pushed a commit to Netyyyy/azure-sdk-for-java that referenced this pull request Jun 28, 2024
* add base class: recurrence range, recurrence pattern

* add object mapper in time window filter for parsing the config string to time window settings

* implement the logic about recurrence evaluator

* add validations

* add test case for validator

* add test case for evaluator

* add more test case

* add more test case

* add calculateClosestStart method to calculate the closest occurrence

* rename function

* add cache logic

* update README.md

* update cache service

* ci

* ci

* move to parent path to make the package name shorter

* update copy right

* address comments: update README.md

* address comment: update the parameter to keep consistent

* address comment: update the sescription to be clearer

* address comment: update logic

* address comment: rename symbol to make easier understanding

* address comment: extract common function to a util class

* address comment: rename symbol to make easier understanding

* address comment: simplify code

* address comment: move to models folder

* revert cache logic

* address comment: make the functions of RecurrenceEvaluator as static functions

* address comment: move the validations to each property file

* add test case in FeatureManagerTest

* address comment: simplify code

* address comment: throw exceptions directly

* address comment: move the related logic to the function to improve the readability

* address comment: make as static method

* address comment: extract variables to avoid multi caller

* address comment: remove `convertToWeekDayNumber` method, no need any more

* address comment: simplify code

* address comment: remove unused code

* address comment: rename symbol

* address comment: add invalid settings check. Start and End must both non-null when Recurrence is not null

* address comment: code style

* address comment: add more test cases

* address comment: removed unused method

* address comment: update symbols

* address comment: adjust spaces

* address comment: add more test case

* address comment: update the README.md

* address comment: code style

* address comment: typo error fix

* address comment: typo error fix

* address comment: update README.md

* address comment: update README.md

* Update sdk/spring/spring-cloud-azure-feature-management/README.md

Co-authored-by: Matthew Metcalf <mrm9084@gmail.com>

* Update sdk/spring/spring-cloud-azure-feature-management/README.md

Co-authored-by: Matthew Metcalf <mrm9084@gmail.com>

* address comment: fix error in yaml example

* address comment: update README.md

* Update sdk/spring/spring-cloud-azure-feature-management/src/main/java/com/azure/spring/cloud/feature/management/filters/TimeWindowFilter.java

Co-authored-by: Matthew Metcalf <mrm9084@gmail.com>

* address comment: add @throws to java doc

* address comment: add "ignoreUnknown" annotation

* address comment: add year info to make it clearer

* address comment: add test case for time with RFC format

* address comment: fix build error

* address comment: update the test case. Should use `assertThrows` instead of catching the exception

* address comment: update the error message to make it clearer

* update README file

* log error and then throw exception

* address comment: update to support handler lower camel case

* address comment: update code style

* address comment: update to use "Microsoft.TimeWindow"

---------

Co-authored-by: Matthew Metcalf <mrm9084@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-spring All azure-spring related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants