-
Notifications
You must be signed in to change notification settings - Fork 85
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
Event Operator and Processor #2136
base: next
Are you sure you want to change the base?
Conversation
Signed-off-by: Amber Torrise <at895452@broadcom.net>
Signed-off-by: Amber Torrise <at895452@broadcom.net>
Signed-off-by: Amber Torrise <at895452@broadcom.net>
Signed-off-by: Amber Torrise <at895452@broadcom.net>
Signed-off-by: Amber Torrise <at895452@broadcom.net>
Signed-off-by: Amber Torrise <at895452@broadcom.net>
Signed-off-by: Amber Torrise <at895452@broadcom.net>
Signed-off-by: Amber Torrise <at895452@broadcom.net>
… a WIP of first iteration idea change Signed-off-by: Amber Torrise <at895452@broadcom.net>
Signed-off-by: Amber Torrise <at895452@broadcom.net>
Signed-off-by: Amber Torrise <at895452@broadcom.net>
Signed-off-by: Amber Torrise <at895452@broadcom.net>
…sses to index for exporting Signed-off-by: Amber Torrise <at895452@broadcom.net>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## next #2136 +/- ##
==========================================
- Coverage 91.20% 83.28% -7.93%
==========================================
Files 628 631 +3
Lines 17877 17927 +50
Branches 3750 3685 -65
==========================================
- Hits 16305 14930 -1375
- Misses 1571 2996 +1425
Partials 1 1 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Amber Torrise <at895452@broadcom.net>
…custEventsPt2 Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com>
WIP-test: trying to fix integration tests first Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com>
…tsPt2 Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com>
@@ -9,7 +9,7 @@ | |||
* | |||
*/ | |||
|
|||
import { IImperativeEventJson, ImperativeEventEmitter, ImperativeSharedEvents } from "../../.."; | |||
import { IImperativeEventJson as EventJson, EventUtils, IEventJson, ImperativeEventEmitter, ImperativeSharedEvents } from "../../.."; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com>
…ew interface implementation Signed-off-by: Amber Torrise <at895452@broadcom.net>
Signed-off-by: Amber Torrise <at895452@broadcom.net>
…cessor Signed-off-by: Amber Torrise <at895452@broadcom.net> Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com>
…cessor Signed-off-by: Amber Torrise <at895452@broadcom.net> Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com>
… custEventsPt2
…ency Signed-off-by: Amber Torrise <at895452@broadcom.net>
Signed-off-by: Amber Torrise <at895452@broadcom.net>
Signed-off-by: Amber Torrise <at895452@broadcom.net>
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.
Consumers, who were not in your design meetings, will not understand why an EventOperator, EventProcessor and EventEmitter exist, nor how they should use them. I suggest that we provide more explanation in block comments on the classes themselves and on some of the more prominent functions to describe how we intend these items to be used. I called out a couple specific examples in the code to give an idea of what I am thinking.
I will continue reviewing other details in this pull request, but I wanted to post this early round of comments for your consideration.
|
||
/** | ||
* Manages event processors for different applications, facilitating subscription, | ||
* emission, and watching of events. |
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.
This is where a caller will start using our set of event technology. That makes this the best place to provide an overview of what the technology is about (including some things implemented in other classes).
Use this block comment to define an EventOperator, and the watchers, emitters, EmitterAndWatchers that are managed by an EventOperator. Provide more context of how an app uses the EventOperator to acquire and manage different watchers, and emitters. Point out when an app should get a processor for emitting versus watching. Clarify the kinds of things the app should do with a given EventProcessor. Explain how the getXXX functions returns different interfaces which restrict which operations you can perform with that particular EventProcessor.
Describe how a processor is tied to an app name and why. Explain that pre-existing, well-defined zowe events exist and can be watched. Point to where a caller can find such names. Explain that custom events can be defined by an arbitrary app. Explain that the valid app names are in our list of extenders (which are the formal plugin names or ZE extender names).
|
||
/** | ||
* Retrieves a Zowe-specific event processor. | ||
* |
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.
Explain why a user would get one of these and what they would do with it.
|
||
/** | ||
* Manages event subscriptions and emissions for a specific application. | ||
* |
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.
Elaborate on what it means to the caller to emit an event. Explain why a caller might want to subscribe to an event. Explain that subscribing involves supplying a callback function. Define what a shared event is versus a user event.
Warning
Wait for changes, don't review
Overview
The
EventOperator
class is a singleton controller for managingEventProcessor
instances. It organizes event management for applications by mapping each application's name to an event processor, which manages and fires callbacks provided by the subscriber to a given application-specific event.Example Use Case
To better understand this organization, imagine you have a Notepad application that wants to subscribe to events from a Calculator application to display the numbers typed in the Calculator:
EventProcessor
instance with watch permissions for the Calculator from theEventOperator
.Design Pattern
Instances of
EventProcessor
are stored within a static map insideEventOperator
, keyed by application names. This prevents cross-application event collisions, maintains a clean separation of events, and allows multiple applications to subscribe to the same application-specific events efficiently.Functionality
EventOperator
manages singleton instances ofEventProcessor
for different applications.EventProcessor
, it retrieves the existing instance for that application if it already exists, or creates a new one if it doesn't. This ensures that only oneEventProcessor
instance exists for a given application.EventProcessor
manages its own subscriptions, handling the addition, emission, and removal of events. It uses a map where event names are the keys, and the values areEvent
objects that hold detailed event information and its list of subscriptions.Code Examples
Event Types Explained
Within our system, events are categorized into four main types:
~/.zowe/.events/$userEventName
$ZOWE_CLI_HOME/.events/$sharedEventName
~/.zowe/.events/$appName/$customSharedEventName
$ZOWE_CLI_HOME/.events/$appName/$customSharedEventName
How to Test
Remaining Work
Review Checklist
I certify that I have: