-
Notifications
You must be signed in to change notification settings - Fork 112
Should schema.Schema, Fields and FieldValidators be splitt into a compiled and uncompiled type? #194
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
Comments
PS! Not something I am going to work on anytime soon. |
Interesting idea. |
Plausible interface. To illustrate with today's naming (i.e. without #77): type Index interface {
GetResource(name string) query.Resource
}
type Type interface{
Validator(field Field, idx Index) (FieldValidator, error)
Serializer(field Field, idx Index) (FieldSerializer, error)
} Where the new If assuming type Type interface{
Parser(field Schema, idx Index) (Parser, error)
Serializer(field Schema, idx Index) (Serializer, error)
} Initially Perhaps the interface also need one of these: FieldGetter(field Schema, idx Index) (FieldGetter, error) That is used by PS! I was contemplating letting the Validator and Serializer be extracted on index.Bind, but that would be to early mainly for two reasons:
Some less well founded remarks: Later, as part of #109, the resource and index could perhaps be redesigned to not do an explicit compile but instead expose methods for retriveing the |
Will close issues that relates to a broader redesign of the schema package (such as this one), leaving only #77 open. |
A discussion in #109 suggest distinguishing between a
resource.IndexBuilder
(allows adding resources, and returning a compiled index) andresource.Index
(allows finding active resources and fetching items).There are some reasons that could make it worthwhile to take a similar approach for schema.Schema:
schema.IDField
, to mention one). When the Field definition is reused in multiple schemas, or the same schema is compiled multiple times in parallel, e.g. for tests, a data race condition arise. When CIs run the tests with race detection enabled, they are likely to fail..Compile
would be a method on aFieldValidatorBuilder
returning aFieldValidator
(naming not final).This changes should be considered alongside other potentially large schema package changes, such as #77, that basically suggests allowing any FieldValidator to be used a the Schema top-level.
The text was updated successfully, but these errors were encountered: