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

Improve the EventFilter API #1981

Closed
appetrosyan opened this issue Mar 17, 2022 · 1 comment
Closed

Improve the EventFilter API #1981

appetrosyan opened this issue Mar 17, 2022 · 1 comment
Assignees
Labels
iroha2-dev The re-implementation of a BFT hyperledger in RUST Refactor Improvement to overall code quality UI Something about the interface

Comments

@appetrosyan
Copy link
Contributor

appetrosyan commented Mar 17, 2022

Currently any user of the EventFilter API needs to retain in their head the entire hierarchy of events and their relationships. This is extremely cumbersome, especially given that we have the FilterOpt structure, which is not the same as Option.

@appetrosyan appetrosyan added the iroha2-dev The re-implementation of a BFT hyperledger in RUST label Mar 17, 2022
@appetrosyan appetrosyan added Refactor Improvement to overall code quality UI Something about the interface labels Dec 15, 2022
@mversic
Copy link
Contributor

mversic commented Dec 7, 2023

likely related to #3068. @DCNick3 please consider it

@hyperledger-iroha hyperledger-iroha deleted a comment from mversic Dec 7, 2023
DCNick3 added a commit to DCNick3/iroha that referenced this issue Jan 29, 2024
…he event filters

- rename the `Filter` trait to `EventFilter`
- "manually" implement all the event filters circumventing the macro
  - as a consequence, move all the filters to a separate module
- change the filter types naming scheme to be more logical:
  - AccountFilter -> AccountEventFilter (filters the event as a whole: by origin id and event type)
  - AccountEventFilter -> AccountEventMatcher (matches over a type of event)
- flattens the event filter hierarchy (account event is a kind of domain event, but account event filter is not)

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Jan 29, 2024
… event filter derive macro

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Jan 29, 2024
…he event filters

- rename the `Filter` trait to `EventFilter`
- "manually" implement all the event filters circumventing the macro
  - as a consequence, move all the filters to a separate module
- change the filter types naming scheme to be more logical:
  - AccountFilter -> AccountEventFilter (filters the event as a whole: by origin id and event type)
  - AccountEventFilter -> AccountEventMatcher (matches over a type of event)
- flattens the event filter hierarchy (account event is a kind of domain event, but account event filter is not)

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Jan 29, 2024
… event filter derive macro

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 2, 2024
… event filter derive macro

- Remove the FilterOpt combinator, fuse it with DataEventFilter
- Rename DataEntityFilter to DataEventFilter
- Add `Any` suffix to nested events matchers
- Add doc-comments to event filters & their variants

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 2, 2024
…he event filters (even further)

- Remove the FilterOpt combinator, fuse it with DataEventFilter
- Rename DataEntityFilter to DataEventFilter
- Add `Any` suffix to nested events matchers
- Add doc-comments to event filters & their variants

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 2, 2024
…he event filters (even further)

- Remove the FilterOpt combinator, fuse it with DataEventFilter
- Rename DataEntityFilter to DataEventFilter
- Add `Any` suffix to nested events matchers
- Add doc-comments to event filters & their variants

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 6, 2024
…he event filters (even further)

- Remove the FilterOpt combinator, fuse it with DataEventFilter
- Rename DataEntityFilter to DataEventFilter
- Add `Any` suffix to nested events matchers
- Add doc-comments to event filters & their variants

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 6, 2024
…terBox and TriggeringFilterBox to EventFilterBox and TriggeringEventFilterBox

To make it consistent with the renamed EventFilter trait

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 6, 2024
…he event filters (even further)

- Remove the FilterOpt combinator, fuse it with DataEventFilter
- Rename DataEntityFilter to DataEventFilter
- Add `Any` suffix to nested events matchers
- Add doc-comments to event filters & their variants

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 6, 2024
…terBox and TriggeringFilterBox to EventFilterBox and TriggeringEventFilterBox

To make it consistent with the renamed EventFilter trait

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 6, 2024
…terBox and TriggeringFilterBox to EventFilterBox and TriggeringEventFilterBox

To make it consistent with the renamed EventFilter trait

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
…he event filters

- rename the `Filter` trait to `EventFilter`
- "manually" implement all the event filters circumventing the macro
  - as a consequence, move all the filters to a separate module
- change the filter types naming scheme to be more logical:
  - AccountFilter -> AccountEventFilter (filters the event as a whole: by origin id and event type)
  - AccountEventFilter -> AccountEventMatcher (matches over a type of event)
- flattens the event filter hierarchy (account event is a kind of domain event, but account event filter is not)

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
… event filter derive macro

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
…he event filters (even further)

- Remove the FilterOpt combinator, fuse it with DataEventFilter
- Rename DataEntityFilter to DataEventFilter
- Add `Any` suffix to nested events matchers
- Add doc-comments to event filters & their variants

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
…terBox and TriggeringFilterBox to EventFilterBox and TriggeringEventFilterBox

To make it consistent with the renamed EventFilter trait

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
…n_for_events and friends implicitly convert event filter types

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
…r-iroha#3068: Unify various event filter APIs, introduce a fluent builder API

- All event filters implement Debug, Clone, Eq, Ord
- All event filters (except TimeEventFilter) have a similar fluent builder API
    Event filter starts by accepting anything, with each method call limiting the accepted events
- Structs with hidden fields provide getters & builder APIs to create them
- Data event matchers are no longer prefixed with `By` to make them read better inside the `only_events` method call

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
…he event filters

- rename the `Filter` trait to `EventFilter`
- "manually" implement all the event filters circumventing the macro
  - as a consequence, move all the filters to a separate module
- change the filter types naming scheme to be more logical:
  - AccountFilter -> AccountEventFilter (filters the event as a whole: by origin id and event type)
  - AccountEventFilter -> AccountEventMatcher (matches over a type of event)
- flattens the event filter hierarchy (account event is a kind of domain event, but account event filter is not)

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
… event filter derive macro

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
…he event filters (even further)

- Remove the FilterOpt combinator, fuse it with DataEventFilter
- Rename DataEntityFilter to DataEventFilter
- Add `Any` suffix to nested events matchers
- Add doc-comments to event filters & their variants

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
…terBox and TriggeringFilterBox to EventFilterBox and TriggeringEventFilterBox

To make it consistent with the renamed EventFilter trait

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
…n_for_events and friends implicitly convert event filter types

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Add an event set proc macro

This proc macro generates a wrapper around a bit mask to specifying a set of events to match

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Use the auto-generated event sets instead of handwritten matchers

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: match more exhaustively over events in DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>

[refactor] hyperledger-iroha#1981, hyperledger-iroha#4195, hyperledger-iroha#3068: match more exhaustively over events in DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Add event filters for PermissionTokenSchemaUpdate, Configuration and Executor events

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Remove some more redundancy when constructing event filters

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Update event filter builder methods naming

Follow the pattern of [event filter] for_X everywhere

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Remove NotificationEvent

Instead of it, expose TriggerCompletedEvent as a top-level event, same as ExecuteTriggerEvent

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Add an event set proc macro

This proc macro generates a wrapper around a bit mask to specifying a set of events to match

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Use the auto-generated event sets instead of handwritten matchers

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: match more exhaustively over events in DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>

[refactor] hyperledger-iroha#1981, hyperledger-iroha#4195, hyperledger-iroha#3068: match more exhaustively over events in DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Add event filters for PermissionTokenSchemaUpdate, Configuration and Executor events

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Remove some more redundancy when constructing event filters

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Update event filter builder methods naming

Follow the pattern of [event filter] for_X everywhere

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Remove NotificationEvent

Instead of it, expose TriggerCompletedEvent as a top-level event, same as ExecuteTriggerEvent

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
- rename the `Filter` trait to `EventFilter`
- "manually" implement all the event filters circumventing the macro
  - as a consequence, move all the filters to a separate module
- change the filter types naming scheme to be more logical:
  - AccountFilter -> AccountEventFilter (filters the event as a whole: by origin id and event type)
  - AccountEventFilter -> AccountEventMatcher (matches over a type of event)
- flattens the event filter hierarchy (account event is a kind of domain event, but account event filter is not)

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
DCNick3 added a commit that referenced this issue Mar 18, 2024
- Remove the FilterOpt combinator, fuse it with DataEventFilter
- Rename DataEntityFilter to DataEventFilter
- Add `Any` suffix to nested events matchers
- Add doc-comments to event filters & their variants

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…EventFilterBox and TriggeringEventFilterBox

To make it consistent with the renamed EventFilter trait

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…y convert event filter types

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…oduce a fluent builder API

- All event filters implement Debug, Clone, Eq, Ord
- All event filters (except TimeEventFilter) have a similar fluent builder API
    Event filter starts by accepting anything, with each method call limiting the accepted events
- Structs with hidden fields provide getters & builder APIs to create them
- Data event matchers are no longer prefixed with `By` to make them read better inside the `only_events` method call

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
This proc macro generates a wrapper around a bit mask to specifying a set of events to match

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…tead of handwritten matchers

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…n DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>

[refactor] #1981, #4195, #3068: match more exhaustively over events in DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…SchemaUpdate, Configuration and Executor events

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…tructing event filters

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…aming

Follow the pattern of [event filter] for_X everywhere

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
Instead of it, expose TriggerCompletedEvent as a top-level event, same as ExecuteTriggerEvent

Signed-off-by: Nikita Strygin <[email protected]>
@DCNick3 DCNick3 closed this as completed Mar 19, 2024
@DCNick3 DCNick3 reopened this Mar 19, 2024
@DCNick3 DCNick3 closed this as completed Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iroha2-dev The re-implementation of a BFT hyperledger in RUST Refactor Improvement to overall code quality UI Something about the interface
Projects
None yet
Development

No branches or pull requests

3 participants