-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add Announcements #268
Comments
The network is a good candidate to add a first announcement resonate/internal/kernel/t_aio/network.go Line 22 in 7935e1c
|
Add a custom event struct. The only required parameter is type Event struct {
Type string
data map[string]interface{}
}
func NewEvent(type string, initialData ...map[string]interface{}) *Event {
var data map[string]interface{}
if len(initialData) > 0 {
data = initialData[0] // Use the first map provided if any.
} else {
data = make(map[string]interface{})
}
return &Event{
Type: eventType,
data: data
}
}
// Set adds or updates a key with a given value.
func (e *Event) Set(key string, value interface{}) {
e.data[key] = value
}
// Get tries to retrieve a value of the specified type T from the event data. It returns the zero value and an error if the type does not match.
func [T any](e *Event) Get[T any](key string) (T, error) {
value, exists := e.data[key]
if !exists {
var zero T
panic("key %s does not exist in event of type %s", key, e.Type)
}
typedValue, ok := value.(T)
if !ok {
panic("value at key %s is not of the requested type in event of type %s", key, e.Type)
}
return typedValue, nil
} |
Regarding announcements: The announcement (the event) should contain all (relevant) application level information. For example, in the context of networking, the event should contain the url, http method, and http body |
Describe the problem you are facing
Resonate's Deterministic Simulation Testing cannot observe the Resonate Server beyond the request/response API. E.g. the Deterministic Simulation Testing cannot observe if notifications are actually sent.
Describe the solution you'd like
P-Lang style announcements & monitors. With announcements and monitors, DST will be able to verify that e.g. announcements are sent if a corresponding subscription exists.
Implementation Details
Step 1
Create a package
announcements
.Step 2
Define an interface
Announcement
with a functionStep 3
Define two different implementations:
NopAnnouncement
DstAnnouncement
Step 4
Use a package-level private variable to hold a singleton instance. Instantiate the correct singleton instance based on config parameter on startup e.g.
Step 5
Implement the interface
Nop
This will simply implement the Announce method without performing any operations.Dst
This will need to safely add the announcement data to an array for later verification. Ensure thread safetyThe text was updated successfully, but these errors were encountered: