Skip to content

Multiple Read/Write Backends #4

@hhenrichsen

Description

@hhenrichsen

Create some sort of parser that can turn something like this:

playerdata:
  # If results should be cached instead of pulled from the write source (default true)
  cache: true
  # Flush cache to storage every X seconds
  interval: 120
  # If write operations should be executed off the main thread (default true)
  async: true
  # Cache lifetime in seconds (set to 0 to disable)
  lifetime: 120
  
  # Where to read data from
  read:
    type: flatfile

  # Where to write data to
  write:
    type: mysql
    host: localhost
    port: 3306
    user: admin
    pass: hunter2

And convert it into proper ManagerReads and ManagerWrites. Ideally these are not generated at runtime and are provided to the determiner, so something like:

val playerDataManager = Manager.buildFromConfig(
    NamespacedKey("ShatteredCore", "playerdata"), // Manager key
    File(module.folder, "datasources.yaml"), // Config location
    "playerdata", // Key in config
    mapOf("flatfile" to FlatfilePlayerDataReads), // Read mapping
    mapOf("mysql" to MySQLPlayerDataWrites) // Write mapping
)

I'm definitely open to discussion here on what this should look like. Maybe we can inject stuff and pull things from the container based on some interface instead of manually constructing a map, or create a set of well-defined reads and writes?

I'd like to keep as much of the storage settings in the users hands as possible, though. That way people can scale things as they like. Perhaps we can provide multiple default configs for this that get copied out, too, so we have sane defaults for small and larger servers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions