Skip to content

Commit 39db25b

Browse files
authored
Merge pull request #77 from binnn6/main
fix context logic
2 parents 1c415c2 + 830635b commit 39db25b

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

context/context.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,10 +750,37 @@ func hasPlugin(plugins []string, target string) bool {
750750
}
751751

752752
func GetRuntimeContext() (RuntimeContext, error) {
753-
if ctx, err := parseContext(); err != nil {
753+
ctx, err := parseContext()
754+
if err != nil {
754755
return nil, err
755-
} else {
756-
return ctx, nil
756+
}
757+
return ctx, nil
758+
}
759+
760+
func CloneRuntimeContext(ctx RuntimeContext) RuntimeContext {
761+
return &FunctionContext{
762+
763+
Name: ctx.GetName(),
764+
Version: ctx.GetContext().Version,
765+
Inputs: ctx.GetInputs(),
766+
Outputs: ctx.GetOutputs(),
767+
768+
Runtime: ctx.GetRuntime(),
769+
Port: ctx.GetPort(),
770+
State: ctx.GetContext().State,
771+
772+
PrePlugins: ctx.GetPrePlugins(),
773+
PostPlugins: ctx.GetPostPlugins(),
774+
PluginsTracing: ctx.GetContext().PluginsTracing,
775+
HttpPattern: ctx.GetHttpPattern(),
776+
777+
Event: &EventRequest{},
778+
SyncRequest: &SyncRequest{},
779+
mode: ctx.GetMode(),
780+
podName: ctx.GetPodName(),
781+
podNamespace: ctx.GetPodNamespace(),
782+
options: ctx.GetContext().options,
783+
daprClient: ctx.GetContext().daprClient,
757784
}
758785
}
759786

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)