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

feat(generic): PB DynamicGo support importDirs #1293

Merged
merged 1 commit into from
Mar 12, 2024
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
11 changes: 11 additions & 0 deletions pkg/generic/jsonpb_test/idl/echo_import.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";
package test;

import "echo.proto";
// The greeting service definition.
option go_package = "./";


service EchoService {
rpc Echo (test.Request) returns (test.Response) {}
}
4 changes: 2 additions & 2 deletions pkg/generic/pbidl_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ func (p *PbContentProvider) Close() error {
}

// PbFileProviderWithDynamicGo
func NewPbFileProviderWithDynamicGo(main string, ctx context.Context, options dproto.Options) (PbDescriptorProviderDynamicGo, error) {
func NewPbFileProviderWithDynamicGo(main string, ctx context.Context, options dproto.Options, importDirs ...string) (PbDescriptorProviderDynamicGo, error) {
p := &PbFileProviderWithDynamicGo{
svcs: make(chan *dproto.ServiceDescriptor, 1),
}

svc, err := options.NewDescriptorFromPath(ctx, main)
svc, err := options.NewDescriptorFromPath(ctx, main, importDirs...)
if err != nil {
return nil, err
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/generic/pbidl_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,15 @@ func TestPbContentProviderDynamicGo(t *testing.T) {
svcDsc := <-p.Provide()
test.Assert(t, svcDsc != nil)
}

func TestPbFileProviderWithDynamicGo(t *testing.T) {
path := "./jsonpb_test/idl/echo_import.proto"

opts := dproto.Options{}
p, err := NewPbFileProviderWithDynamicGo(path, context.Background(), opts, "./jsonpb_test/idl")

test.Assert(t, err == nil)

svcDsc := <-p.Provide()
test.Assert(t, svcDsc != nil)
}
Loading