Skip to content

Commit

Permalink
fix context logic
Browse files Browse the repository at this point in the history
Signed-off-by: binnnliu <[email protected]>
  • Loading branch information
binnnliu committed Nov 16, 2023
1 parent 1c415c2 commit 7b616e9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7b616e9

Please sign in to comment.