spiral-modules / php-grpc

:electric_plug: Fast and furious GRPC server for PHP applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I cannot set in .rr.yml Proto which includes other protos

oneslash opened this issue · comments

commented

I cannot set in .rr.yml Proto which includes other protos.

It does not work for some reason

Can you attach sample proto file and describe the issue in more details.

commented

Category.proto

syntax = "proto3";
package pim.v1;

message Category {
    uint32 id = 1;
    string name = 2;
}

Product.proto

syntax = "proto3";
package product;
import "v1/category.proto";

message Product {
    uint32 id = 1;
    string name = 2;
    Category primary_category = 3;
}

and my .rr.yml is


grpc:
  listen: "tcp://:9001"
  proto: "./vendor/app/product.proto"
  workers:
    command: "php app.php"
    pool:
      numWorkers: 4

What is the error you experiencing? I'm not seeing any services defined in your proto files, have you generated your service code?

commented

@wolfy-j yes, I have services, in both files.

service CategoryService {
    rpc CreateCategory (CategoryCreateRequest) returns (CategoryCreateResponse) {};

    rpc ReadCategory (CategoryReadRequest) returns (CategoryReadResponse) {};
}
ProductService {
    // Price Related
    rpc UpdatePrice (ProductPriceRequest) returns (ProductPriceResponse) {}
}
commented

error is it cannot find the service in category

It would be hard for me to identify the issue this way. If you can post the minimal reproducible version of your code it would help a lot.

When you saying "error is it cannot find the service in category", do you mean it is not able to generate the code for this service or this service does not respond on GPRC request?

commented

the error was

{
 “error”: “12 UNIMPLEMENTED: unknown service pim.v1.CategoryService”
}

If it is not enough we can try to send a small code

Yes, please submit the code sample. Thank you

commented

so there is the commit with changes https://github.com/oneslash/php-grpc/commit/3b878bb5b4df94fba5174e3c40a252d8ff0b784a

the test TestParseFile will fail since it can't find two services

func TestParseFile(t *testing.T) {
	services, err := File("test.proto")
	assert.NoError(t, err)
	assert.Len(t, services, 2)

	assert.Equal(t, "app.namespace", services[0].Package)
}

Thank you, this helps a lot.

Fixed in 1.0.4

commented

Thank you, I will check soon and report back if it works