TUN-3015: Add a new cap'n'proto RPC interface for connection registration as well as matching client and server implementations. The old interface extends the new one for backward compatibility.

This commit is contained in:
Igor Postelnik
2020-06-02 13:19:19 -05:00
committed by Adam Chalmers
parent dc3a228d51
commit 448a7798f7
8 changed files with 1743 additions and 128 deletions

53
tunnelrpc/pogs/errors.go Normal file
View File

@@ -0,0 +1,53 @@
package pogs
import (
"fmt"
"time"
)
type RetryableError struct {
err error
Delay time.Duration
}
func (re *RetryableError) Error() string {
return re.err.Error()
}
// RetryErrorAfter wraps err to indicate that client should retry after delay
func RetryErrorAfter(err error, delay time.Duration) *RetryableError {
return &RetryableError{
err: err,
Delay: delay,
}
}
func (re *RetryableError) Unwrap() error {
return re.err
}
// RPCError is used to indicate errors returned by the RPC subsystem rather
// than failure of a remote operation
type RPCError struct {
err error
}
func (re *RPCError) Error() string {
return re.err.Error()
}
func wrapRPCError(err error) *RPCError {
return &RPCError{
err: err,
}
}
func newRPCError(format string, args ...interface{}) *RPCError {
return &RPCError{
fmt.Errorf(format, args...),
}
}
func (re *RPCError) Unwrap() error {
return re.err
}