Skip to content

Commit

Permalink
fix: not need streaming mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Marina-Sakai committed Nov 14, 2024
1 parent 4ef13e1 commit 930282c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
15 changes: 2 additions & 13 deletions thrift/descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ type FunctionDescriptor struct {
name string
endpoints []http.Endpoint
annotations []parser.Annotation
isClientStreaming bool
isServerStreaming bool
isWithoutWrapping bool
}

// Name returns the name of the function
Expand Down Expand Up @@ -379,19 +378,9 @@ func (f FunctionDescriptor) Annotations() []parser.Annotation {
return f.annotations
}

// IsClientStreaming returns if the function is client streaming
func (f FunctionDescriptor) IsClientStreaming() bool {
return f.isClientStreaming
}

// IsServerStreaming returns if the function is server streaming
func (f FunctionDescriptor) IsServerStreaming() bool {
return f.isServerStreaming
}

// IsWithoutWrapping returns if the request and response are not wrapped in struct
func (f FunctionDescriptor) IsWithoutWrapping() bool {
return f.isClientStreaming || f.isServerStreaming
return f.isWithoutWrapping
}

// ServiceDescriptor is the runtime descriptor of a service
Expand Down
3 changes: 1 addition & 2 deletions thrift/idl.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,7 @@ func addFunction(ctx context.Context, fn *parser.Function, tree *parser.Thrift,
hasRequestBase: hasRequestBase,
endpoints: enpdoints,
annotations: annos,
isClientStreaming: st.ClientStreaming,
isServerStreaming: st.ServerStreaming,
isWithoutWrapping: isStreaming,
}
sDsc.functions[fn.Name] = fnDsc
return nil
Expand Down
10 changes: 5 additions & 5 deletions thrift/idl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,12 @@ func TestStreamingFunctionDescriptorFromContent(t *testing.T) {
`
dsc, err := NewDescritorFromContent(context.Background(), path, content, nil, false)
require.Nil(t, err)
require.Equal(t, true, dsc.Functions()["Echo"].IsClientStreaming())
require.Equal(t, true, dsc.Functions()["EchoServer"].IsServerStreaming())
require.Equal(t, false, dsc.Functions()["EchoUnary"].IsClientStreaming())
require.Equal(t, true, dsc.Functions()["EchoBizException"].IsClientStreaming())
require.Equal(t, true, dsc.Functions()["Echo"].IsWithoutWrapping())
require.Equal(t, true, dsc.Functions()["EchoClient"].IsWithoutWrapping())
require.Equal(t, "Request", dsc.Functions()["EchoClient"].Request().Struct().Name())
require.Equal(t, true, dsc.Functions()["EchoServer"].IsWithoutWrapping())
require.Equal(t, false, dsc.Functions()["EchoUnary"].IsWithoutWrapping())
require.Equal(t, true, dsc.Functions()["EchoBizException"].IsWithoutWrapping())
require.Equal(t, false, dsc.Functions()["EchoPingPong"].IsWithoutWrapping())
require.Equal(t, "Request", dsc.Functions()["EchoClient"].Request().Struct().Name())
require.Equal(t, "", dsc.Functions()["EchoUnary"].Request().Struct().Name())
}

0 comments on commit 930282c

Please sign in to comment.