diff --git a/context/context.go b/context/context.go index 2c2d7f1..cf4d2a8 100644 --- a/context/context.go +++ b/context/context.go @@ -757,6 +757,33 @@ func GetRuntimeContext() (RuntimeContext, error) { } } +func CloneRuntimeContext(ctx RuntimeContext) RuntimeContext { + return &FunctionContext{ + + Name: ctx.GetName(), + Version: ctx.GetContext().Version, + Inputs: ctx.GetInputs(), + Outputs: ctx.GetOutputs(), + + Runtime: ctx.GetRuntime(), + Port: ctx.GetPort(), + State: ctx.GetContext().State, + + PrePlugins: ctx.GetPrePlugins(), + PostPlugins: ctx.GetPostPlugins(), + PluginsTracing: ctx.GetContext().PluginsTracing, + HttpPattern: ctx.GetHttpPattern(), + + Event: &EventRequest{}, + SyncRequest: &SyncRequest{}, + mode: ctx.GetMode(), + podName: ctx.GetPodName(), + podNamespace: ctx.GetPodNamespace(), + options: ctx.GetContext().options, + daprClient: ctx.GetContext().daprClient, + } +} + func parseContext() (*FunctionContext, error) { ctx := &FunctionContext{ Inputs: make(map[string]*Input), diff --git a/runtime/runtime.go b/runtime/runtime.go index 89332d5..c0d6dcf 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -49,7 +49,7 @@ type RuntimeManager struct { } func NewRuntimeManager(funcContext ofctx.RuntimeContext, prePlugin []plugin.Plugin, postPlugin []plugin.Plugin) *RuntimeManager { - ctx := funcContext + ctx := ofctx.CloneRuntimeContext(funcContext) rm := &RuntimeManager{ FuncContext: ctx, prePlugins: prePlugin,