Skip to content

Commit

Permalink
Merge pull request #77 from binnn6/main
Browse files Browse the repository at this point in the history
fix context logic
  • Loading branch information
benjaminhuo authored Nov 22, 2023
2 parents 1c415c2 + 830635b commit 39db25b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
33 changes: 30 additions & 3 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,10 +750,37 @@ func hasPlugin(plugins []string, target string) bool {
}

func GetRuntimeContext() (RuntimeContext, error) {
if ctx, err := parseContext(); err != nil {
ctx, err := parseContext()
if err != nil {
return nil, err
} else {
return ctx, nil
}
return ctx, nil
}

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,
}
}

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 39db25b

Please sign in to comment.