0

I'd like to be able to have a list of values available to a web service where the contents of that list can be preconfigured to change starting on a given date.

For example, let's say we had a new feature that was rolling out in the USA on a state by state basis.

Let's say that starting on 2018-09-01, the allowed states are: NJ, NY, PA.

Then, as the rollout continues, starting on 2018-10-01, the allowed states are: NJ, NY, PA, and MA and CT.

And later, starting on 2019-01-01, the allowed states are: NJ, NY, PA, MA, CT, and VT and ME.

Ideally, additional dates and state lists could be updated without stopping and starting the service (without any new build/deployment activity).

What's the best way to implement this?

So far I can think of how to do this using a separate SQL database (table with date column and list column, select row with newest date that doesn't exceed otday's date), but I'm hoping to avoid the complexity of standing up a database for this.

James Daily
  • 587
  • 6
  • 21

1 Answers1

0

Solution I'm using for now:

  • Describe rules in an external XML file
  • Make that XML file available to the service
  • Use Xpath expressions to "query" the XML to execute the rules against inputs to the service

For example:

<?xml version="1.0" encoding="UTF-8"?>
<ExampleRulesXML>
    <ApprovedStates>
        <State code="NY" approvedDate="2018-09-01"/>
        <State code="TX" approvedDate="2018-10-01"/>
        <State code="VT" approvedDate="2018-10-01"/>
        <State code="CA" approvedDate="2018-11-01"/>
    </ApprovedStates>
</ExampleRulesXML>

If the inputs are "2018-09-15" and "NY" (New York), I'd construct the following Xpath, which would evaluate to true, indicating the state is approved as of this date:

exists(/ExampleRulesXML/ApprovedStates/State[@code="NY"][@approvedDate <= "2018-09-15"])

If the inputs are "2018-09-15" and "TX" (Texas), I'd construct the following Xpath, which would evaluate to false, indicating the state is not yet approved as of this date:

exists(/ExampleRulesXML/ApprovedStates/State[@code="TX"][@approvedDate <= "2018-09-15"])
James Daily
  • 587
  • 6
  • 21