Skip to content

My Niche Use Cases #494

Description

@nelsam

This is kinda a maintenance question. I was a maintainer on testify and gorp for a long time, so I know how many headaches you can get maintaining all sorts of features for niche use cases. How do you (i.e. the maintainers on this repo) feel about supporting super niche cases?

The tl;dr is that I wrote some features into a fork of toml intending to submit them as PRs, then felt the maintenance burden in my soul when I looked at the diff. I don't want to put that on you folks unless you think it's worth your time. Do you want to support my weird use cases? I'm happy to make a few PRs, but I don't want to delve too deep in the weeds if it's just going to waste your time.

My niche case(s):

  1. I need to pass in pre-filled data, i.e. filled with default values. When I unmarshal a file to that data, I only want it to overwrite data in the fields if the file contains data for those fields. Currently, structs work this way, but maps don't. One of my data structures requires a map, and the default values in that map get wiped out when I use this repo to unmarshal data.
  2. I need to unmarshal several files from a conf.d directory to the same destination. Values from each file overwrite values from the previous files. This kind of rolls up into the issue from [1] - structs work fine, maps do not. Primitives only store the most recently decoded file.
  3. I need to support lazy decoders - types that do not yet know their child structure. I can almost get there with Primitive, but since I am unmarshaling several files, the Primitive's context and undecoded values lose track of data from previous files. They need to know which MetaData they got those values from (and probably track multiple MetaData values) in order to decode the right data.
  4. I need to pause lazy decoding part of the way through in order to save the current data. I have two folders - a dflt.d storing defaults from previous versions, and a conf.d storing user-customized data. I don't want new defaults to overwrite previous defaults, but I do want to save defaults for any settings that didn't exist in the previous version. So I load previous defaults from a dflt.d directory and then save the current config struct to a file. After saving that file, I resume decoding the user-defined files. MetaData plus Primitive is almost enough, but the changes needed to handle it are non-trivial.

I solved [1] and most of [2] in #491, but as I solved [3] it started to look like a lot of code changes ... and [4] just made me think that I'm probably going to be wasting your time. I wrote my own (semi-naive) toml parser to handle my niche cases instead. But before I plow forward with that long-term, I wanted to open a discussion. How do you folks feel about supporting niche use cases like that? If you think there's value to these features in this repo, I can shift my changes to a PR.

But it feels like a lot of features for a single user (it doesn't seem like anyone else has hit these yet), so I am also happy to maintain my own parser that just handles my specific use case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions