From 26ef19f49b9f5505be9863eeac52d7747e3df255 Mon Sep 17 00:00:00 2001 From: laminar Date: Thu, 30 Dec 2021 20:22:16 +0800 Subject: [PATCH] fix: change default dapr grpc client port to "50001" Signed-off-by: laminar --- functionframeworks/frameworks.go | 8 ++++---- openfunction-context/context.go | 5 +---- openfunction-context/types.go | 18 ++++++++---------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/functionframeworks/frameworks.go b/functionframeworks/frameworks.go index 4cfe412..8cca1f0 100644 --- a/functionframeworks/frameworks.go +++ b/functionframeworks/frameworks.go @@ -54,7 +54,7 @@ func RegisterOpenFunction(ctx context.Context, fn func(*ofctx.OpenFunctionContex var funcErr error if fctx.DaprClient == nil { - fctx.DaprClient = getDaprClient(fctx.ClientPort) + fctx.DaprClient = getDaprClient() } // Serving function with inputs @@ -164,7 +164,7 @@ func Start() error { if err != nil { port := os.Getenv("PORT") if port == "" { - port = ofctx.DefaultKnaitvePort + port = ofctx.DefaultPort } err = startKnative(port) } else { @@ -208,10 +208,10 @@ func writeHTTPErrorResponse(w http.ResponseWriter, statusCode int, status, msg s fmt.Fprintf(w, msg) } -func getDaprClient(port string) daprClient.Client { +func getDaprClient() daprClient.Client { mu.Lock() defer mu.Unlock() - c, e := daprClient.NewClientWithPort(port) + c, e := daprClient.NewClientWithPort(ofctx.DefaultDaprGRPCClientPort) if e != nil { panic(e) } diff --git a/openfunction-context/context.go b/openfunction-context/context.go index 9ee459e..2e0dda5 100644 --- a/openfunction-context/context.go +++ b/openfunction-context/context.go @@ -58,12 +58,9 @@ func GetOpenFunctionContext() (*OpenFunctionContext, error) { } if ctx.Port == "" { - ctx.Port = DefaultOpenFuncAsyncPort + ctx.Port = DefaultPort } - if ctx.ClientPort == "" { - ctx.ClientPort = DefaultDaprClientPort - } } ctx.Event = &EventMetadata{} diff --git a/openfunction-context/types.go b/openfunction-context/types.go index d4fd9f4..5381190 100644 --- a/openfunction-context/types.go +++ b/openfunction-context/types.go @@ -6,15 +6,14 @@ import ( ) const ( - OpenFuncAsync Runtime = "OpenFuncAsync" - Knative Runtime = "Knative" - OpenFuncBinding ResourceType = "bindings" - OpenFuncTopic ResourceType = "pubsub" - Success ReturnCode = 200 - InternalError ReturnCode = 500 - DefaultOpenFuncAsyncPort = "50001" - DefaultKnaitvePort = "8080" - DefaultDaprClientPort = "44543" + OpenFuncAsync Runtime = "OpenFuncAsync" + Knative Runtime = "Knative" + OpenFuncBinding ResourceType = "bindings" + OpenFuncTopic ResourceType = "pubsub" + Success ReturnCode = 200 + InternalError ReturnCode = 500 + DefaultPort = "8080" + DefaultDaprGRPCClientPort = "50001" ) type OpenFunctionContext struct { @@ -25,7 +24,6 @@ type OpenFunctionContext struct { Outputs map[string]*Output `json:"outputs,omitempty"` Runtime Runtime `json:"runtime"` Port string `json:"port,omitempty"` - ClientPort string `json:"clientPort,omitempty"` State interface{} `json:"state,omitempty"` Event *EventMetadata `json:"event,omitempty"` DaprClient daprClient.Client