This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* notification implementation: Initial changes * TDD notification: tested basic functionality with memory storage * attending review comments and fixes to the sse * autoincrement ID * supporting query parameters and only the difference on update notifications * adding leveldb support to store the older events * taking storage dsn from config and starting the id from 0 * improved logging * Update NOTICE * remove redundant MIT license text * addressing the reveiw comments * reverting print verb * eventType moved to wot package * minor refactoring * renaming the storage to eventQueue * renaming the local variable to avoid confusion Co-authored-by: Shreekantha Devasya <[email protected]>
- Loading branch information
Showing
13 changed files
with
612 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package catalog | ||
|
||
// EventListener interface that listens to TDD events. | ||
type EventListener interface { | ||
CreateHandler(new ThingDescription) error | ||
UpdateHandler(old ThingDescription, new ThingDescription) error | ||
DeleteHandler(old ThingDescription) error | ||
} | ||
|
||
// eventHandler implements sequential fav-out/fan-in of events from registry | ||
type eventHandler []EventListener | ||
|
||
func (h eventHandler) created(new ThingDescription) error { | ||
for i := range h { | ||
err := h[i].CreateHandler(new) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (h eventHandler) updated(old ThingDescription, new ThingDescription) error { | ||
for i := range h { | ||
err := h[i].UpdateHandler(old, new) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (h eventHandler) deleted(old ThingDescription) error { | ||
for i := range h { | ||
err := h[i].DeleteHandler(old) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.