Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultClientTimeout = 5 * time.Second
DefaultClientTimeout is the recommended timeout for the client.
View Source
var DefaultRetryOptions = RetryOptions{ Base: time.Second, Max: 5 * time.Second, Factor: 0.2, }
DefaultRetryOptions are the recommended retry settings.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a http.Client with a fixed timeout.
func (Client) SendRequest ¶
func (c Client) SendRequest(ctx context.Context, url string, request jsonrpc.Request, options *RetryOptions) (jsonrpc.Response, error)
SendRequest sends the `jsonrpc.Request` to the given URL. It only retries sending the request if the retry options are non-nil. Otherwise it returns the response and error immediately.
type RequestWithResponder ¶
type RequestWithResponder struct {
Context context.Context
ID interface{}
Method string
Params interface{}
Responder chan jsonrpc.Response
Query url.Values
}
func NewRequestWithResponder ¶
func NewRequestWithResponder(ctx context.Context, id interface{}, method string, params interface{}, query url.Values) RequestWithResponder
NewRequestWithResponder constructs a new SubmitTx request wrapper object.
func (RequestWithResponder) IsMessage ¶
func (RequestWithResponder) IsMessage()
IsMessage implements the `phi.Message` interface.
func (RequestWithResponder) RespondWithErr ¶
func (req RequestWithResponder) RespondWithErr(code int, err error)
type RetryOptions ¶
type RetryOptions struct {
Base time.Duration // Time interval before first retry.
Max time.Duration // Maximum time interval between two retries.
Factor float64 // next_interval = previous_interval * (1 + factor)
}
RetryOptions are used for retrying failed requests sent using the client.
Click to show internal directories.
Click to hide internal directories.