Skip to content

Commit e16793d

Browse files
committed
fix context logic
Signed-off-by: binnn6 <[email protected]>
1 parent 1c415c2 commit e16793d

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

context/context.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,34 @@ func hasPlugin(plugins []string, target string) bool {
752752
func GetRuntimeContext() (RuntimeContext, error) {
753753
if ctx, err := parseContext(); err != nil {
754754
return nil, err
755-
} else {
756-
return ctx, nil
755+
}
756+
return ctx, nil
757+
}
758+
759+
func CloneRuntimeContext(ctx RuntimeContext) RuntimeContext {
760+
return &FunctionContext{
761+
762+
Name: ctx.GetName(),
763+
Version: ctx.GetContext().Version,
764+
Inputs: ctx.GetInputs(),
765+
Outputs: ctx.GetOutputs(),
766+
767+
Runtime: ctx.GetRuntime(),
768+
Port: ctx.GetPort(),
769+
State: ctx.GetContext().State,
770+
771+
PrePlugins: ctx.GetPrePlugins(),
772+
PostPlugins: ctx.GetPostPlugins(),
773+
PluginsTracing: ctx.GetContext().PluginsTracing,
774+
HttpPattern: ctx.GetHttpPattern(),
775+
776+
Event: &EventRequest{},
777+
SyncRequest: &SyncRequest{},
778+
mode: ctx.GetMode(),
779+
podName: ctx.GetPodName(),
780+
podNamespace: ctx.GetPodNamespace(),
781+
options: ctx.GetContext().options,
782+
daprClient: ctx.GetContext().daprClient,
757783
}
758784
}
759785

runtime/runtime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type RuntimeManager struct {
4949
}
5050

5151
func NewRuntimeManager(funcContext ofctx.RuntimeContext, prePlugin []plugin.Plugin, postPlugin []plugin.Plugin) *RuntimeManager {
52-
ctx := funcContext
52+
ctx := ofctx.CloneRuntimeContext(funcContext)
5353
rm := &RuntimeManager{
5454
FuncContext: ctx,
5555
prePlugins: prePlugin,

0 commit comments

Comments
 (0)