Re: [grpc-io] Re: java concurrent ordered response buffer

2021-05-05 Thread 'Eric Anderson' via grpc.io
On Wed, Apr 28, 2021 at 12:57 AM Piotr Morgwai Kotarbinski <
morg...@gmail.com> wrote:

> I was surprised actually, because I thought parallel request message
> processing was a common use-case, both for gRPC and websockets
>

Yeah, we call those "RPCs." They can scale very wide horizontally.

(for example if we have a service that does some single-threaded graphic
> processing on received images and sends back a modified version of a given
> image, it would be most efficient to dispatch the processing to a thread
> pool with a size corresponding to available CPU/GPU cores, right? As
> processing them sequentially would utilize just 1 core per request stream,
> so in case of low number of concurrent request streams, we would be
> underutilizing the cores).
>

What's more rare is to have in-order processing (using a stream) that *can* be
split to multiple threads, as in-order and multi-threaded tend to be
at-odds. If you are just processing images, then you can commonly process
them each individually and would use separate RPCs. For
in-order+multi-threaded, you need to cut up the input data in a
server-specific way (e.g., I-frame frequency for video encoding), do
heavy-lifting in a thread-for-each-chunk, and then recombine in the end.
(If it isn't server-specific, the client is more likely to do the cutting.)
The cutting and merging easily become application-specific. Although your
tool would probably help many cases even with application-specific logic,
it's just not a common enough case for us to have utilities on hand. I
think I've seen most of such cases show up in server→client processing,
like pubsub, where the server is actually sending work to the client yet
can't "just do another RPC" to the client.

That said, I'm certain there are others that will be happy to pick up and
use your code. Thanks for posting it!

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CA%2B4M1oO2SbvMdt5gQnBon%2BisJgtRzDH4_k%3DxY1GSHXqyQafLwA%40mail.gmail.com.


smime.p7s
Description: S/MIME Cryptographic Signature


Re: [grpc-io] Re: java concurrent ordered response buffer

2021-05-05 Thread Piotr Morgwai Kotarbinski
to fulfill the void left by my previous message  ;-)  here is 
ConcurrentRequestObserver which eases up developing bi-di streaming methods 
that dispatch work to other threads but don't need to preserve order of 
responses:

https://github.com/morgwai/grpc-utils/blob/master/src/main/java/pl/morgwai/base/grpc/utils/ConcurrentRequestObserver.java

it handles all the synchronization and manual flow control to maintain the 
desired concurrency level while also preventing an excessive response 
messages buffering.
This one is gRPC specific as  websockets do not have half-closing and 
manual flow control, so not much left to ease-up there  ;-]

Cheers!

On Friday, April 30, 2021 at 4:10:25 PM UTC+7 Piotr Morgwai Kotarbinski 
wrote:

> please note that this class should only be used if the response messages 
> order requirement cannot be dropped: if you control a given proto interface 
> definition, then it's more efficient to add some unique id to request 
> messages, include it in response messages and send them as soon as they are 
> produced, so nothing needs to be buffered.
>
> Cheers!
>
> On Friday, April 30, 2021 at 8:59:11 AM UTC+7 nitish bhardwaj wrote:
>
>>
>> Thanks for contributing  *OrderedConcurrentOutputBuffer. * I totally 
>> agree, this would be really useful to utilize cores efficiently.
>>
>>
>> On Wednesday, April 28, 2021 at 1:27:46 PM UTC+5:30 mor...@gmail.com 
>> wrote:
>>
>>> Thanks :)
>>>
>>> I was surprised actually, because I thought parallel request message 
>>> processing was a common use-case, both for gRPC and websockets
>>> (for example if we have a service that does some single-threaded graphic 
>>> processing on received images and sends back a modified version of a given 
>>> image, it would be most efficient to dispatch the processing to a thread 
>>> pool with a size corresponding to available CPU/GPU cores, right? As 
>>> processing them sequentially would utilize just 1 core per request stream, 
>>> so in case of low number of concurrent request streams, we would be 
>>> underutilizing the cores).
>>>
>>> Cheers! 
>>>
>>> On Wednesday, April 28, 2021 at 6:52:08 AM UTC+7 Eric Anderson wrote:
>>>
 Yeah, we don't have anything pre-existing that does something like 
 that; it gets into the specifics of your use-case. Making something 
 yourself was appropriate. I will say that the strategy used in 
 OrderedConcurrentOutputBuffer with the Buckets seems really clean.

 On Thu, Apr 22, 2021 at 9:21 AM Piotr Morgwai Kotarbinski <
 mor...@gmail.com> wrote:

> in case someone needs it also, I've written it myself due to lack of 
> answers either here and on SO:
>
> https://github.com/morgwai/java-utils/blob/master/src/main/java/pl/morgwai/base/utils/OrderedConcurrentOutputBuffer.java
> feedback is welcome :)
> On Tuesday, April 20, 2021 at 11:09:59 PM UTC+7 Piotr Morgwai 
> Kotarbinski wrote:
>
>> Hello
>> i have a stream of messages coming from a websocket or a grpc client. 
>> for each message my service produces 0 or more reply messages. by 
>> default 
>> both websocket endpoints and grpc request observers are guaranteed to be 
>> called by maximum 1 thread concurrently, so my replies are sent in the 
>> same 
>> order as requests. Now I want to dispatch request processing to other 
>> threads and process them in parallel, but still keep the order. 
>> Therefore, 
>> I need some "concurrent ordered response buffer", which will buffer 
>> replies 
>> to a given request message until processing of previous requests is 
>> finished and replies to them are sent (in order they were produced 
>> within 
>> each "request bucket").
>>
>> I can develop such class myself, but it seems a common case, so I was 
>> wondering if maybe such thing already exists (to not reinvent the 
>> wheel). 
>> however I could not easily find anything on the web nor get any answer 
>> on 
>> SO 
>> 
>> . does anyone knows about something like this?
>>
>> Thanks!
>>
> -- 
> You received this message because you are subscribed to the Google 
> Groups "grpc.io" group.
> To unsubscribe from this group and stop receiving emails from it, send 
> an email to grpc-io+u...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/grpc-io/e7107eed-fa35-4b2e-8d5a-5754e0a37740n%40googlegroups.com
>  
> 
> .
>


-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discuss

[grpc-io] Re: How to unit test grpc services api in ci/cd

2021-05-05 Thread 'AJ Heller' via grpc.io
Hi Sunandan. For unit tests, it's first worth trying to test your business 
logic in isolation from gRPC. For integration tests, you could run your 
service and exercise it with test clients (your CI environment may be 
opinionated on how to automate that). We also have a doc that offers one 
suggestion as to how you might test client 
logic https://github.com/grpc/grpc/blob/master/doc/unit_testing.md
On Sunday, May 2, 2021 at 9:10:10 AM UTC-7 sunanda...@gmail.com wrote:

> Hi,
> I am using unit test framework like catch2. Can any one suggest how to 
> test my grpc service APIs.
> Regards,
> Sunandan 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/50915e66-eee2-4ed5-86ee-b9b8eed8616cn%40googlegroups.com.


[grpc-io] How do I combine proto buf definitions from separate name spaces in a single proto buf file?

2021-05-05 Thread John Buczkowski
I'm building out a series of ProtoBuf definitions for a .NetCore gRPC 
application.
I'm using the Orchestrator pattern as I will be creating a series of 
microservices.

I am running into issues with my proto definitions throwing compiler errors 
as being "undefined."
The definitions are in several different files (with different C# 
namespaces).
What follows is a simplified version of my definitions.

Consider the following protobuf files:

**service.proto**

syntax = "proto3";
option csharp_namespace = "RequestHandlerService";
package test;

service Handler
{
  rpc AddItem1(G_RequestType1) returns (G_RequestResponse) { }
  rpc AddItem2(G_RequestType2) returns (G_RequestResponse) { }
}

message G_RequestType1{
  string originId = 1;
  string request = 2;
}

message G_RequestType2{
  string originId = 1;
  string request = 2;
}

message G_RequestResponse{
  string response = 1;
}


**windowsservice.proto:**

syntax = "proto3";
import "google/protobuf/timestamp.proto";
option csharp_namespace = "Windows.RequestHandler.Service";
package windows.requesthandler.service;

service WindowsHandler
{
rpc Action1(G_Action1Request) returns (G_Action1Response) { }
rpc Action2(G_Action2Request) returns (G_Action2Reponse) { }
}

message G_Action1Request{
string transactionId = 1;
google.protobuf.Timestamp DateTimeStamp = 2;
string filePath = 3;
}

message G_Action2Request{
string transactionId = 1;
google.protobuf.Timestamp DateTimeStamp = 2;
string textToInsert = 3;
}

message G_Action1Response {
google.protobuf.Timestamp DateTimeStamp = 1;
string fileSecurityStatusMessage = 2;
G_Action1Request action1Request = 3;
}

message G_Action2Response {
google.protobuf.Timestamp DateTimeStamp = 1;
string fileModifierStatusMessage = 2;
G_Action2Request action2Request = 3;
}


message G_WindowsRequest {
int32 requestId = 1;
oneof RequestType{
G_Action1Request action1Request = 2;
G_Action2Request action2Requestion = 3;
}
}

message G_WindowsRequestResponse {
bool wasSuccessful = 1;
string response = 2;
oneof ResponseType{
G_Action1Response action1Response = 3;
G_Action2Response action2Respone = 4;
}
}


**orchestrator.proto**

syntax = "proto3";
option csharp_namespace = "OrchestratorService";
package test;

import "service.proto";
import "windowsservice.proto";

service Orchestrator
{
  rpc RegisterClient(G_RegisterClientRequest) returns (stream 
G_Response) { }
  rpc EnqueueRequest(G_OrchestrationRequest) returns (G_Response) { }
}

message G_OrchestrationRequest{
  string originId = 1;
  oneof RequestType{
G_RequestType1 requestType1 = 2;
G_RequestType2 requestType2 = 3;
G_Response response = 4;
G_WindowsRequest windowsRequest = 5;
G_WindowsRequestResponse windowsRequestResponse = 6;
  }
}

message G_RegisterClientRequest{
  string clientId = 1;
}

message G_Response{
  bool wasSuccessful = 1;
  string response = 2;
}

Here is the  definition from the csproj file for my Orchestrator 
project:

 

Protos/orchestrator.proto


Protos/service.proto


  Protos/windowservice.proto



Both **G_WindowsRequest** and **G_WindowsRequestResponse** are throwing a 
compiler error saying they are undefined. Is this an issue with 
**csharp_namespace** and/or **package** resolution?

Is there a way to enforce separate package/csharp_namespace definitions 
within the separate proto definitions, but reference those definitions 
within the rolled up "orchestrator" proto file definition?


**Here is a snippet of the compiler errors I am seeing:**

> 2>  orchestrator.proto(22,5): error : "G_WindowsRequest" is not
> defined. 2>  orchestrator.proto(23,5): error :
> "G_WindowsRequestResponse" is not defined. 2>Done building target
> "_Protobuf_CoreCompile" in project "Protos.csproj" -- FAILED. 2>
> 2>Done building project "Protos.csproj" -- FAILED. 2> 2>Build FAILED.
> 2> 2>orchestrator.proto(22,5): error : "G_WindowsRequest" is not
> defined. 2>orchestrator.proto(23,5): error :
> "G_WindowsRequestResponse" is not defined. 2>0 Warning(s) 2>2
> Error(s)

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/3fbd4e41-390c-4dfe-9cc1-676ae95d9caan%40googlegroups.com.


[grpc-io] How to Generate the Server and Client Libraries in NodeJS

2021-05-05 Thread Dan Wilson
I am quite new to gRPC but I wish to use it in my current application.

I am building the Backend Server in NodeJS

I have created my Service Definition file as below:

```syntax = "proto3";

package location;

import "protos/auth.proto";

service LocationManager{
rpc updateLocation(LocationUpdateRequest) returns (LocationUpdateResponse);
}

enum LocationUpdateTarget{
CUSTOMER = 0;
RIDER = 1;
}

message Location{
 double longitude = 3;
 double latitude = 4;
}

message LocationUpdateRequest{
auth.AuthParams authParams = 1;
LocationUpdateTarget locationUpdateTarget = 2;
Location location = 3;
}

message LocationUpdateResponse{
int32 statusCode = 1;
}
```
How do I generate the NodeJS Client Libraries for My Server and The Client.

The Documentations isn't clear about this.

Thank you.


-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/77ab97c1-497f-48bc-9320-356af46b683dn%40googlegroups.com.