Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix some typos #48

Merged
merged 2 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions pkg/function/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import (
"runtime"
"strconv"

functionpb "github.com/numaproj/numaflow-go/pkg/apis/proto/function/v1"
"github.com/numaproj/numaflow-go/pkg/function"
"github.com/numaproj/numaflow-go/pkg/info"
_ "go.uber.org/automaxprocs"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/resolver"
"google.golang.org/protobuf/types/known/emptypb"

functionpb "github.com/numaproj/numaflow-go/pkg/apis/proto/function/v1"
"github.com/numaproj/numaflow-go/pkg/function"
"github.com/numaproj/numaflow-go/pkg/info"
)

// client contains the grpc connection and the grpc client.
Expand All @@ -29,8 +30,8 @@ type client struct {
// New creates a new client object.
func New(inputOptions ...Option) (*client, error) {
var opts = &options{
maxMessageSize: function.DefaultMaxMessageSize,
sereverInfoFilePath: info.ServerInfoFilePath,
maxMessageSize: function.DefaultMaxMessageSize,
serverInfoFilePath: info.ServerInfoFilePath,
}

// Populate connection variables for client connection
Expand All @@ -47,7 +48,7 @@ func New(inputOptions ...Option) (*client, error) {
}

// TODO: WaitUntilReady() check unitl SIGTERM is received.
serverInfo, err := info.Read(info.WithServerInfoFilePath(opts.sereverInfoFilePath))
serverInfo, err := info.Read(info.WithServerInfoFilePath(opts.serverInfoFilePath))
if err != nil {
// TODO: return nil, err
log.Println("Failed to execute info.Read(): ", err)
Expand Down
8 changes: 4 additions & 4 deletions pkg/function/client/options.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package client

type options struct {
sockAddr string
maxMessageSize int
sereverInfoFilePath string
sockAddr string
maxMessageSize int
serverInfoFilePath string
}

// Option is the interface to apply options.
Expand All @@ -26,6 +26,6 @@ func WithMaxMessageSize(size int) Option {
// WithServerInfoFilePath sets the server info file path to the given path.
func WithServerInfoFilePath(f string) Option {
return func(o *options) {
o.sereverInfoFilePath = f
o.serverInfoFilePath = f
}
}
1 change: 0 additions & 1 deletion pkg/function/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func Test_server_map(t *testing.T) {
}()

serverInfoFile, err := os.CreateTemp("/tmp", "numaflow-test-info")
fmt.Println(serverInfoFile.Name())
assert.NoError(t, err)
defer func() {
err = os.RemoveAll(serverInfoFile.Name())
Expand Down
9 changes: 7 additions & 2 deletions pkg/info/server_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@ func Test_WaitUntilReady(t *testing.T) {
}

func Test_Read_Write(t *testing.T) {
filepath := os.TempDir() + "/server-info"
filepath := os.TempDir() + "server-info"
defer os.Remove(filepath)
info := &ServerInfo{Protocol: UDS, Language: Go, Version: ""}
info := &ServerInfo{
Protocol: TCP,
Language: Java,
Version: "11",
Metadata: map[string]string{"key1": "value1", "key2": "value2"},
}
Comment on lines +57 to +62
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I update this line to match unit test in Java SDK such that I can verify the output files are identical between Go and Java. Feel convenient to keep it.

err := Write(info, WithServerInfoFilePath(filepath))
assert.NoError(t, err)
got, err := Read(WithServerInfoFilePath("/tmp/not-exist"))
Expand Down
8 changes: 4 additions & 4 deletions pkg/info/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const (

// ServerInfo is the information about the server
type ServerInfo struct {
Protocol Protocol `json:"protocol"`
Language Language `json:"language"`
Version string `json:"version"`
Metaddata map[string]string `json:"metadata"`
Protocol Protocol `json:"protocol"`
Language Language `json:"language"`
Version string `json:"version"`
Metadata map[string]string `json:"metadata"`
}