mediachain / L-SPACE

[DEPRECATED] Books = Knowledge = Power = (Mass x Distance^2) / Time^3
MIT License
9 stars 1 forks source link

Replace Spray with gRPC #64

Closed parkan closed 8 years ago

parkan commented 8 years ago

This shouldn't be too hard given that we have all the query logic pretty neatly packaged in CanonicalQueries. Main things to do are

bigs commented 8 years ago

:+1:

yusefnapora commented 8 years ago

This is getting close; I'm going to try to have a PR up in the next hour or so...

I'm checking out the error situation at the moment. Right now we're throwing a RuntimeException in the server implementation if we can't fulfill the request. In the JVM client this gets wrapped in an io.grpc.StatusRuntimeException, with a string representation of the original exception as the cause.

The scala client implementation returns Option[Response] for each endpoint and wraps calls to the server with try/catch. If it gets a StatusRuntimeException it logs to the console and returns None.

So e.g. client.fetchCanonical("Foo!") will return None and log:

WARNING: RPC request failed: Status{code=UNKNOWN, description=null, cause=java.lang.RuntimeException: Canonical not found}

I'm not crazy about the code=UNKNOWN, description=null bit and having all the meaningful info packed into a string.... but I think it'll do for now.

It looks like the gRPC team is working on adding custom metadata to error responses, so we can probably afford to wait on that instead of rolling our own solution.