-
Notifications
You must be signed in to change notification settings - Fork 80
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
feat(sdk): Enable Custom Trigger Registration #587
feat(sdk): Enable Custom Trigger Registration #587
Conversation
0a8f667
to
cebda27
Compare
I used the same string/factory function map approach as in edgexfoundry/go-mod-messaging#75 Happy to do something more robust if need be. I was torn on whether or not to turn MessageError into a normal error for return from ProcessMessageFunc and decided to keep it simple for now but that is easy enough to add as well. |
Codecov Report
@@ Coverage Diff @@
## master #587 +/- ##
==========================================
+ Coverage 61.76% 61.80% +0.04%
==========================================
Files 31 32 +1
Lines 1810 1846 +36
==========================================
+ Hits 1118 1141 +23
- Misses 619 631 +12
- Partials 73 74 +1
Continue to review full report at Codecov.
|
Before I rebase I think I'm going to add an internal method to the SDK to provide a 'starter' appcontext seeded with clients, config etc..... |
cebda27
to
e595e1c
Compare
That should be better I just changed the builder function to take the same signature as the MQTT trigger |
c7b974f
to
f81c328
Compare
7a3b32b
to
123c7b3
Compare
Sorry for the chatter on this one - I wanted to check if anyone had any ideas as I worked through it. I've settled on a pair of functions to pass from the SDK to custom triggers - one to process messages on the runtime, and another to build an appcontext.Context for a given message. Its still a little awkward - I'm trying to not expose the BindingInfo type I need for the trigger, so I access it on construction by creating a fake appcontext.Context and reading through the configuration pointer available there. Other than that it feels pretty decent to use. I think the context building function may be useful for #599 as well would just be a matter of incorporating in the built in triggers. |
123c7b3
to
27d96ca
Compare
Here is an example trigger that I have been using to test with kafka: https://github.com/AlexCuse/edgex-watermill/blob/master/core/watermilltrigger.go |
fdab45b
to
083785a
Compare
I added a new type TriggerConfig that provides a container to pass the necessary bits to construct a trigger from the SDK. Its still a little broad right now (I wonder about how to get to a generic broker config - I just use MessageBus currently) but better than opening up the whole SDK I think. |
083785a
to
9df6351
Compare
This branch should be up to date now. |
9df6351
to
c18f6a6
Compare
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.
Overall this is great! Just a few minor nits. ;-)
95f303c
to
8b097a4
Compare
accept registration of factory functions for making custom trigger types available to the SDK Signed-off-by: Alex Ullrich <alexullrich@technotects.com>
8b097a4
to
109166e
Compare
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
Introduce an example for the custom trigger functionality introduced to the SDK in edgexfoundry/app-functions-sdk-go#587
Introduce an example for the custom trigger functionality introduced to the SDK in edgexfoundry/app-functions-sdk-go#587 Signed-off-by: Alex Ullrich <alexullrich@technotects.com>
Introduce an example for the custom trigger functionality introduced to the SDK in edgexfoundry/app-functions-sdk-go#587 Signed-off-by: Alex Ullrich <alexullrich@technotects.com>
Introduce an example for the custom trigger functionality introduced to the SDK in edgexfoundry/app-functions-sdk-go#587 Signed-off-by: Alex Ullrich <alexullrich@technotects.com>
Introduce an example for the custom trigger functionality introduced to the SDK in edgexfoundry/app-functions-sdk-go#587 Signed-off-by: Alex Ullrich <alexullrich@technotects.com>
accept registration of factory functions for making custom trigger types
available to the SDK
Signed-off-by: Alex Ullrich alexullrich@technotects.com
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #586
What is the new behavior?
Allow registering custom trigger builders to be used when initializing trigger to run the service.
Does this PR introduce a breaking change?
Are there any new imports or modules? If so, what are they used for and why?
No
Are there any specific instructions or things that should be known prior to reviewing?
Other information