Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move RequiredIdOptionPolicy and RequiredIdOptionPolicy to McJava #135

Open
alexander-yevsyukov opened this issue Sep 23, 2024 · 1 comment

Comments

@alexander-yevsyukov
Copy link
Collaborator

Validation has an ability to generate the code for implicitly required fields. Such fields are IDs of corresponding message types.

For example, a command message must have an ID, or an entity state must have an ID, and we do not want to force the user to apply (required)=true all the time. We want to make such rules assumed.

To support this feature we have the MessageMarkers type which allows to filter out message types into the following categories:

  1. Entity states by using the repeated field entity_option_name.
  2. Signal messages (commands, events, rejections) using the fields with FilePattern type.

McJava fills in MessageMarkers (as a part of ValidationConfig) from its settings when passing settings to ValidationPlugin executed by ProtoData.

The problem

The problem with this approach is that it breaks the level of abstraction. Validation should not know about entity states or signals. It's the job of Model Compilers, and McJava in particular.

Validation should have the notion of implicitly required fields and provide API for being informed about such fields from the tools that deal with custom message types. But it should not be organised via passing settings because:

  1. It leaks the abstraction back to Validation.
  2. Supporting more types requires extending MessageMarkers and therefore re-building Validation.

We need to resolve this issue and reduce the coupling between Validation and McJava. Fortunately, we already have the basis for such separation of abstractions: the abstract class RequiredIdPolicy. It has two descendants that handle entity states and signals. These descendants are RequiredIdOptionPolicy and RequiredIdPatternPolicy classes.

Suggested course of actions

  1. Make RequiredIdPolicy public.
  2. Make RequiredIdOptionPolicy a part of EntityPlugin in McJava. The policy would fire the events as it does now under Validation, but taking options directly from McJava.
  3. Similarly to the item above, make RequiredIdPatternPolicy a part of SignalPlugin in McJava.
@alexander-yevsyukov alexander-yevsyukov added this to the M1 milestone Sep 23, 2024
@alexander-yevsyukov
Copy link
Collaborator Author

@armiol, this is the issue on Validation/McJava dependency we've discussed earlier today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant