-
Notifications
You must be signed in to change notification settings - Fork 12
Strongly-typed columns in query/subscription client API #1229
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
Conversation
Now, using parameterized `EntityColumn` and `SubscribableField` types, the filters passed to `where(...)` will be forced to have the target type matching the filtered object.
It now wraps `Field` value instead of `FieldPath`.
…into strongly-typed-columns
…into strongly-typed-columns
The strict field and column parametrization for now is removed.
Also fetched the latest repackaging-related changes from `base`.
…into strongly-typed-columns
Also reworded the warning suppression.
@armiol, @dmdashenkov PTAL. The build should pass once the corresponding changes from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@dmitrykuzmin please also mention the subscription to events — i.e. how it is affected (or not) by this changeset. |
@dmitrykuzmin, please compose a short document which explains using this feature. You can create a Google Doc, and I'll convert it into Markdown placing in the site hierarchy. |
…into strongly-typed-columns
@armiol, @dmdashenkov PTAL again. |
…ongly-typed-columns # Conflicts: # license-report.md # pom.xml
Codecov Report
@@ Coverage Diff @@
## master #1229 +/- ##
=========================================
Coverage ? 90.82%
Complexity ? 4481
=========================================
Files ? 589
Lines ? 14089
Branches ? 776
=========================================
Hits ? 12797
Misses ? 1042
Partials ? 250 |
@alexander-yevsyukov The short document with feature usage explanation can be found here. |
This PR addresses #1212.
It takes advantage of the strongly-typed fields and columns generated by base#508 and embeds them in the high-level client API.
New Client API
The old
where(...)
methods that are accepting plainFilter
andCompositeFilter
instances are now deprecated in favor of new overloads which accept the typed filters as arguments. The typed filters form a hierarchy which mirrors the hierarchy of query and entity/event subscription requests, and are created with help of generated columns and fields.An example of the new API:
The
QueryFilter
andCompositeQueryFilter
are the typed wrappers for theFilter
andCompositeFilter
proto messages respectively. The wrapper creation is regulated by the generated field and column types, not allowing to specifyField
-based filter to a query request and vice-versa.Event subscriptions
The event subscription request also accepts strongly-typed filters, as follows:
The
EventFilter
can be created in multiple ways to enable filtering events by the event context:The
EventContextField
instance may be obtained from theEventContext.Field
class, in the same way as all other strongly-typed fields and columns. So an example of event subscription request could be:On the Protobuf level filtering by event context still works by appending the
"context."
prefix to a field path in the filter.Additional Model Compiler configurations
To enable the behavior described above, the additional Model Compiler configurations are specified:
Basically, they:
spine.core.Event
, as it's a subscribable entity type (seeEEntity
).spine.core.EventContext
with a custom marker superclass, to enable the typed event filter creation described above.Other
The
orderBy(...)
method ofQueryRequest
is also switched to the new columns usage (the old version is deprecated).Please note, that the described changes affect only the high-level Client API. The lower-level API like
TargetBuilder
is still capable of accepting column/field names as plain strings.Version
The Spine version advances to
1.4.5
.