Skip to content

Setting a deadline for a request #68

@michaeldelago

Description

@michaeldelago

Something that seems to be missing is setting a deadline for a request. I can see that setting an infinite deadline is hardcoded into client.cc, but to my (limited) understanding, other grpc implementations (namely Go) take an infinite deadline to mean there isn't a deadline.

Is there a clean way that we can integrate deadlines into this implementation?

in the examples at grpc/grpc, python uses syntax like this (source):

try:
    response = stub.SayHello(
        helloworld_pb2.HelloRequest(name=message), timeout=3
    )
    print(f"Greeter client received: {response.message}")
except grpc.RpcError as rpc_error:
    print(f"Call failed with code: {rpc_error.code()}")

Noting that the syntax for python appears to be emitted from the python protobuf compiler, but that doesn't happen from cl-protobufs.

For CL, I suppose an equivalent would look like this

(handler-case
  (testing-rpc:call-say-hello channel (testing:make-hello-request :name message) :deadline 3)
 (grpc:grpc-call-error (c)
    (format t "call failed due to ~a" c)))

An alternative (and admittedly the first one I thought of) syntax for CL could use lexical variables:

(let ((grpc:*call-deadline* 3))
  (handler-case
    (testing-rpc:call-say-hello channel (testing:make-hello-request :name message))
   (grpc:grpc-call-error (c)
     (format t "call failed due to ~a" c))))

Thoughts? Am I missing on how to use deadlines in this library? If not, how can we implement it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions