Skip to content

Commit d397ef1

Browse files
authored
Merge pull request #55 from zclonely/feat-add-GetInputName-function-for-context-interface
feat: add GetEventInputName func for context interface
2 parents d3f811d + 2c16de6 commit d397ef1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

context/context.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ type Context interface {
194194

195195
// ContextOptions returns the context's options.
196196
ContextOptions() ContextOption
197+
198+
// GetInputName return the inputName of the event
199+
GetInputName() string
197200
}
198201

199202
type Out interface {
@@ -593,6 +596,10 @@ func (ctx *FunctionContext) GetInnerEvent() InnerEvent {
593596
return ctx.Event.innerEvent
594597
}
595598

599+
func (ctx *FunctionContext) GetInputName() string {
600+
return ctx.Event.InputName
601+
}
602+
596603
func (ctx *FunctionContext) GetPluginsTracingCfg() TracingConfig {
597604
return ctx.PluginsTracing
598605
}

runtime/async/async.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,13 @@ func (r *Runtime) RegisterOpenFunction(
9999
// Serving function with inputs
100100
if ctx.HasInputs() {
101101
for name, input := range ctx.GetInputs() {
102+
n := name
102103
switch input.GetType() {
103104
case ofctx.OpenFuncBinding:
104105
input.Uri = input.ComponentName
105106
funcErr = r.handler.AddBindingInvocationHandler(input.Uri, func(c context.Context, in *dapr.BindingEvent) (out []byte, err error) {
106107
rm := runtime.NewRuntimeManager(ctx, prePlugins, postPlugins)
107-
rm.FuncContext.SetEvent(name, in)
108+
rm.FuncContext.SetEvent(n, in)
108109
rm.FunctionRunWrapperWithHooks(rf.GetOpenFunctionFunction())
109110

110111
switch rm.FuncOut.GetCode() {

0 commit comments

Comments
 (0)