Skip to content

Commit

Permalink
fix: change default dapr grpc client port to "50001"
Browse files Browse the repository at this point in the history
Signed-off-by: laminar <[email protected]>
  • Loading branch information
tpiperatgod committed Dec 30, 2021
1 parent d4411cb commit 26ef19f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
8 changes: 4 additions & 4 deletions functionframeworks/frameworks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 1 addition & 4 deletions openfunction-context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand Down
18 changes: 8 additions & 10 deletions openfunction-context/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 26ef19f

Please sign in to comment.