Commit Graph

103 Commits

Author SHA1 Message Date
Kostia Balytskyi
d48c87a95e megarepo: introduce write side of MononokeMegarepoConfigs
Summary:
`MononokeMegarepoConfig` is going to be a single point of access to
config storage system - provide both writes and reads. It is also a trait, to
allow for unit-test implementations later.

This diff introduces a trait, as well as implements the write side of the
configerator-based implementor. The read side/oss impl/test impl
is left `unimplemented`. Read side and test impl will be implemented in the future.

Things I had to consider while implementing this:
- I wanted to store each version of `SyncTargetConfig` in an individual
  `.cconf` in configerator
- at the same time, I did not want all of them to live in the same dir, to
  avoid having dirs with thousands of files in it
- dir sharding uses sha1 of the target repo + target bookmark + version name,
  then separates it into a dir name and a file name, like git does
- this means that these `.cconf` files are not "human-addressable" in the
  configerator repo
- to help this, each new config creation also creates an entry in one of the
  "index" files: human-readable maps from target + version name to a
  corresponding `.cconf`
- using a single index file is also impractical, so these are separated by
  ascification of the repo_id + bookmark name

Note: this design means that there's no automatic way to fetch the list of all
targets in use. This can be bypassed by maintaining an extra index layer, whihc
will list all the targets. I don't think this is very important atm.

Reviewed By: StanislavGlebik

Differential Revision: D27795663

fbshipit-source-id: 4d824ee4320c8be5187915b23e9c9d261c198fe1
2021-04-22 02:13:19 -07:00
Kostia Balytskyi
81675b2d5b megarepo: introduce megarepo_error and make configo_client use it
Summary:
We want to distinguish user vs system errors in `configo_client` and its users
(`mononoke_config` for instance). The reason is to allow `scs_server`
distinguish the two types of errors. Normally user errors would only ever be
instantiated fairly "shallowly" in the `scs_server` itself, but `configo_client`
is a transactional client (by this I mean that it calls user-provided transformation functions on fetched data), so we need to allow for a user error to originate from these updater functions.

Reviewed By: StanislavGlebik

Differential Revision: D27880928

fbshipit-source-id: e00a5580a339fdabc4b858235da9cd7e9fc7a376
2021-04-21 05:02:00 -07:00
Kostia Balytskyi
815b5ad04a megarepo_api: introduce a basic configo client
Summary:
This is not used on its on, but in subsequent diffs I will add a use-case, by
the megarepo configs crate.

When built in non-fbcode mode, this crate does not export anything. I chose this approach as opposed to the approach of exporting no-op stubs to force the clients to pay attention and implement gating their side too. This seems reasonable for a rather generic configo client.

Reviewed By: StanislavGlebik

Differential Revision: D27790753

fbshipit-source-id: d6dcec884ed7aa88abe5796ef0e58be8525893e2
2021-04-19 08:34:12 -07:00