Skip to content

Data-driven config updater #172

@sandtechnology

Description

@sandtechnology

Data structure

Concepts: A new data structure for describing updating config (Json)

Version

The target version for updating from.

Condition

Opcodes

  • EQUALS
  • LOWER
  • GREATER
  • EQUALS_GREATER
  • EQUALS_LOWER

Paths

The config path for comparing

Value

Values for comparing, see below for detailed value representation.

Opcodes

  • NEW: Add a new option in configuration with default value
  • DELETE: Delete an option in configuration
  • PATCH: Change an option current value to other

Value

Value for this opcode, see below for detailed value representation.

Value representation

Needs register before by registering to Serializer which implement following interface:

interface ConfigValueSerializer {
 String getTargetClassName();
 int getVersion();
 @Nullable Object fromString(int version, String input);
 String toString();
}

Then it will be convert to this for example:

{
 "version": 1,
 "targetClass": "java.lang.Boolean",
 "data": "true"
}

Example File

{
 "configPatchList": [{
  "version": 1,
  "patchs": [{
    "opcode": "NEW",
    "path": "foo.example",
    "value": {
     "version": 1,
     "targetClass": "java.lang.Boolean",
     "data": "true"
    },
    "condition": {
     "opcode": "equals",
     "path": "foo.create",
     "value": {
      "version": 1,
      "targetClass": "java.lang.Boolean",
      "data": "true"
     }
    }
   },
   {
    "version": 2,
    "patchs": [{
     "opcode": "PATCH",
     "path": "foo.example",
     "value": {
      "version": 1,
      "targetClass": "java.lang.Boolean",
      "data": "false"
     },
     "condition": {
      "opcode": "foo.example",
      "path": "foo.create",
      "value": {
       "version": 1,
       "targetClass": "java.lang.Boolean",
       "data": "true"
      }
     }
    }]
   }
  ]
 }]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    todowontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions