Home > OS >  grpc nodejs where to put retrypolicy
grpc nodejs where to put retrypolicy

Time:11-10

referencing https://github.com/grpc/proposal/blob/master/A6-client-retries.md

it is not clear where the retry policy is actually placed or referenced, is it part of

 protoLoader.loadSync(PROTO_PATH, {
    keepCase: true,
    longs: String,
    enums: String,
    defaults: true,
    oneofs: true
})

A supplemental question once retry is setup, regarding the call.on('xxxxxx', where in the API docs are the options listed? Using vscode I don't get any lint suggestions, but copilot gave me these, is there a more comprehensive list?

    call.on('end', () => {
      console.log("---END---")
    })
    call.on('error', err => {
      console.log("---ERROR---:" JSON.stringify(err))
    })
    call.on('status', status => {
      console.log("---STATUS---")
    })
    call.on('metadata', metadata => {
      console.log("---METADATA---")
    })
    call.on('cancelled', () => {
      console.log("---CANCELLED---")
    })
    call.on('close', () => {
      console.log("---CLOSE---")
    })
    call.on('finish', () => {
      console.log("---FINISH---")
    })
    call.on('drain', () => {
      console.log("---DRAIN---")
    })
    
    
    
    
    
    

CodePudding user response:

First, the retry functionality is currently not supported in the Node gRPC library (but it is in development).

Second, once the retry functionality is supported, it can be configured in the service config, as specified in the Integration with Service Config section of the proposal you linked. The service config can be provided to the client automatically by the service owner through the name resolution mechanism, or it can be provided when constructing a Client or Channel object by setting the grpc.service_config channel argument with a value that is a string containing a JSON-encoded service config.

Third, the call objects returned when calling methods are Node stream objects with additional events for metadata and status. Depending on how the method is defined in the .proto file, the call can be a Readable stream, a Writable stream, both, or neither, and it will emit the corresponding methods. The cancelled event is only emitted by server call objects, which do not emit the metadata or status events.

  • Related