Commit graph

15 commits

Author SHA1 Message Date
Pavel Karpy
870c1ffc0a [#397] refs: Fix OIDs marshalling
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2022-04-27 09:45:03 +03:00
Evgenii Stratonikov
e8e09f0d00 [#393] rpc/grpc: Use NewTimer instead of time.After
From the docs of `time.After`:
```
The underlying Timer is not recovered by the garbage collector until the timer fires.
```
We have 1 minute default timeout, which is pretty long given that most
of the time we exchange small messages.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-04-21 15:11:57 +03:00
Evgenii Stratonikov
50382114f4 [#383] rpc/client: Export URI-parsing function
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-03-10 19:16:42 +03:00
Alex Vanin
49db0cfa03 [#366] rpc/client: Inherit read-write gRPC timeout from client
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-12-28 12:49:31 +03:00
Alex Vanin
aa53fb7131 [#366] rpc/grpc: Perform read-write message operations with timeout
Remote gRPC server may not return or accept data for a while. gRPC
solves this issue with timeout in context. However, the context is
used for entire gRPC method invocation. Unfortunately the duration
of requests with streams can't be estimated easily.

To solve this issue we can specify timeouts for every message read
and write. Single message has size limit so timeout can be related
to that.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-12-28 12:49:31 +03:00
Leonard Lyubich
25da5d2e13 Add v2 version to go module name
Replace all elements from `v2` to root directory.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-11-17 15:29:33 +03:00
Leonard Lyubich
e459378b16 [#306] grpc: Fix the format of full method names
All calling RPC's should have a leading slash according to docs of using
gRPC library.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-06-15 10:15:40 +03:00
Pavel Karpy
52c1c4c5ab [#290] client: Add WithURIAddress option
Add `WithURIAddress` option to client.
It parses passed address with
`url.ParseRequestURI` function and
use(or not) TLS over grpc connection
based on retrieved scheme('grpc' or
'grpcs').

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2021-06-02 15:55:20 +03:00
Leonard Lyubich
22ce8e13cc [#196] rpc/client: Implement Client.Conn method
Implement `Client.Conn` which returns the connection of the underlying
transport client. The method is going to be used for forwarding the
connection to superior clients.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-31 10:13:00 +03:00
Leonard Lyubich
066a2dba74 [#196] rpc/grpc: Implement Client.Conn method
Implement `Client.Conn` method which returns underlying connection as
`io.Closer`. Method is going to be used for forwarding the connection to
superior clients.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-31 10:13:00 +03:00
Pavel Karpy
89aede1fb3 [#286] client: Add TLS options
Add `WithTLSConfig` option to client.
If it is not nil then client will
try to open secured connection.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2021-05-24 16:56:59 +03:00
Evgenii Stratonikov
9ddfcdfbba [#277] go.mod: remove pkg/errors
Use stdlib `errors` instead.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-05-19 11:14:56 +03:00
Leonard Lyubich
30c6ca0714 [#263] Implement client for exchanging raw Protobuf messages
Implement generic `Client` that can communicate with the remote server via
protobuf `Message`'s. The client can uniformly execute any protobuf RPC
on the remote server using any of the supported transport protocols.
Currently only gRPC protocol is supported.

Additionally implement helpful functions to transmit messages by one of the
flow types: unary, client- or server-side stream.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-03-17 14:03:49 +03:00
Leonard Lyubich
c61656a43f [#263] Define generic protobuf message
Define `Message` interface of the generic protobuf message. In the initial
implementation, the message should be convertible to and from related gRPC
message.

Implement encoding functions over the `Message` that can:

 * unmarshal the `Message` via related gRPC message;
 * decode the `Message` from JSON format via related gRPC message;
 * encode the `Message` to JSON.

Implement nested `test` package for testing the implementation.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-03-17 14:03:49 +03:00
Leonard Lyubich
cf765a61a6 [#263] Implement client for exchanging raw messages using gRPC protocol
Implement gRPC client that can uniformly execute any RPC on the remote
server. In the primary implementation, the client is a thin wrapper over
gRPC client connection that is required to create the client. In the future,
it is planned to expand the library with convenient functionality.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-03-17 14:03:49 +03:00