Supports multiple input sources && Replace int return with ctx.Return #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this pr, I adjusted functions-framework-go from only supporting one input to supporting multiple inputs, and adjusted the return value of the function from a specific code to a Return structure.
The main changes are reflected in the following places:
Firstly, Input(Input) is changed to Inputs(map[string]*Input)
Also added BindingEvent(to store bindings events) and TopicEvent(to store topic events)
Maybe a function like GetData is needed to get the data from the specified input?
Modified the input data to interface{} type, SendTo will automatically wrap the incoming non-[]byte type data in json format automatically. Also modified the return value to add the return data.
A new Return structure has been added to handle the return of the function.
Code indicates the return value of the function and currently supports: Success (200) for the success of the function and InternalError (500) for the exception of the function.
Data, Metadata, Error can be used to store the data, metadata, and error information that needs to be returned. I plan to add some hook configurations for handling function returns later in the evolution, and the return data here will be used by the processing module in the hook.
Signed-off-by: laminar fangtian@kubesphere.io