Preset mappers#449
Conversation
notpeter
left a comment
There was a problem hiding this comment.
At first glance this looks fine.
-
As I mentioned in the other review I don't love the
Ephemeralterm because they can't go away. They are perhaps static, stateless, immutable but ephemeral things are short lived and these are largely immortal. Open to other terms. -
I think this could use a db transaction. Currently
record_mapper_eventis triggered beforeregister_api_user(which could fail). Ideally these would occur in the same transaction so if the user create failed we don't have a mapper_event that didn't actually happen. Not sure how difficult that is to thread, but wanted to mention it. -
No referential integrity for mapper_event.user_id -- often times audit tables intentionally don't have foreign keys (for good reasons) but I think they might be reasonable here.
| match self.consume_mapping_activation(&mapper).await { | ||
| Ok(_) => true, | ||
| Err(err) => { | ||
| // TODO: Inspect the error. We expect to see a conflict error, and |
There was a problem hiding this comment.
Is this comment outdated? I would expect the upsert in consume_mapping_activation wouldn't result in conflicts.
There was a problem hiding this comment.
It is, but noted below that this needs its own PR. That function is actually just incorrect when I went and looked at it.
|
|
Updated naming from Ephemeral to Preset. I think conveys most of what I was hoping for. I think it has a concept of requiring configuration, but also enough of the immutable concept. I was leaning towards Static, but decided against it as it ends up colliding with the Rust |
|
Deferring the work on activations as that needs more work. Consumption needs to be made atomic, as-is the code is incorrect. I'll open a separate issue for it. |
|
Wonderful. LGTM! |
Adds the concept of preset mappers. Preset mappers are mappers that exist only within the runtime memory of the server. Their purpose is to solve a pain point around defining mappers by configuration as opposed to database state.
Main differences:
Generally an application will require at least one mapper rule to bootstrap itself. This is something like an admin group with a user that should be the initial admin. From here, that admin can create groups, and additional dynamic mappers that are stored alongside the data of the application. This bootstrapping mapper is a good use case for an preset mapper. The user defines a configuration for an preset mapper that is passed to the v-api context builder at runtime, and that mapper is installed in memory. An admin can then log in and be granted permissions. On restart, the user can decide if they still want to pass this configuration to the v-api context or not. If they don't then the mapper rule acts as if it never existed.
Because these mappers are preset, we also need to include the ability to record when they are processed. This change adds a log table that records the execution results of mappers so that independent of a mapper being preset or dynamic, we still know when it was used to grant permissions