Documentation
¶
Index ¶
- Constants
- type Client
- type ClientConfig
- type Connection
- func (conn *Connection) Close()
- func (conn *Connection) Connect()
- func (conn *Connection) EndRequest(id uint64)
- func (conn *Connection) GetRequestCount(rType string)
- func (conn *Connection) IsClosed() bool
- func (conn *Connection) ReceiveRequestCount(msg *simple_rpc_message.RPCMessage)
- func (conn *Connection) ReceiveStartRequestAck(msg *simple_rpc_message.RPCMessage)
- func (conn *Connection) RequestCountDone(rType string)
- func (conn *Connection) Send(msg *simple_rpc_message.RPCMessage)
- func (conn *Connection) StartRequest(id uint64, rType string, limit uint32)
- type ErrorHandler
- type PendingRequest
- type RequestCountListener
- type RequestStartAckListener
- type StartedRequest
Constants ¶
const DEFAULT_RETRY_CONNECTION_DELAY = 5 * time.Second
const DEFAULT_TIMEOUT = 10 * time.Second
const HEARTBEAT_MSG_PERIOD_SECONDS = 30
Period to send HEARTBEAT messages to the client
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for the parallel request controller
func (*Client) GetRequestCount ¶
Gets the current number of parallel requests of a type Parameters: - requestType - String to indicate the request type Returns: - count - Current number of parallel requests of the specified type - err - An error that prevented the request count from completing
func (*Client) StartRequest ¶
func (cli *Client) StartRequest(requestType string, limit uint32) (req *StartedRequest, limited bool, err error)
Indicates the start of a request Parameters: - requestType - String to indicate the request type - limit - Máximum number of requests allowed to be run in parallel Returns: - req - Reference to the started request. Keep it to indicate the ending. May be nil in case of error or if the request type reached the limit - limited - True if the limit was reached, so the request should be rejected - err - An error that prevented the request start indication from completing
type ClientConfig ¶
type ClientConfig struct {
// Parallel request controller base URL. Example: ws://example.com:8080
Url string
// Number of connections. 1 by default.
NumberOfConnections int
// Authentication token
AuthToken string
// Delay retry the connection. 5 seconds by default
RetryConnectionDelay time.Duration
// Error handler
ErrorHandler ErrorHandler
// Timeout for receiving responses from the server. By default: 10 seconds
Timeout time.Duration
}
Configuration of the PRC client
func (*ClientConfig) GetFullConnectionUrl ¶
func (config *ClientConfig) GetFullConnectionUrl() (string, error)
Gets full connection URL (with authentication token)
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection to a PRC server
func NewConnection ¶
func NewConnection(cli *Client, config *ClientConfig) *Connection
func (*Connection) EndRequest ¶
func (conn *Connection) EndRequest(id uint64)
Ends a request, by sending the END-REQUEST message
func (*Connection) GetRequestCount ¶
func (conn *Connection) GetRequestCount(rType string)
Sends GET-REQUEST-COUNT message to get the request count for a specific type
func (*Connection) IsClosed ¶
func (conn *Connection) IsClosed() bool
Checks if the client is closed
func (*Connection) ReceiveRequestCount ¶
func (conn *Connection) ReceiveRequestCount(msg *simple_rpc_message.RPCMessage)
Receives REQUEST-COUNT message
func (*Connection) ReceiveStartRequestAck ¶
func (conn *Connection) ReceiveStartRequestAck(msg *simple_rpc_message.RPCMessage)
Receives message: START-REQUEST-ACK
func (*Connection) RequestCountDone ¶
func (conn *Connection) RequestCountDone(rType string)
Call after a request count is done, either by receiving the response or due to timeout
func (*Connection) Send ¶
func (conn *Connection) Send(msg *simple_rpc_message.RPCMessage)
Send a message to the module
func (*Connection) StartRequest ¶
func (conn *Connection) StartRequest(id uint64, rType string, limit uint32)
Starts request, either by sending a START-REQUEST message or waiting for connection
type ErrorHandler ¶
type ErrorHandler interface {
// Called on connection error. The client will retry the connection if not manually closed
OnConnectionError(err error)
// Called when an ERROR message is received from the server
OnServerError(code string, message string)
}
Error handler for the PRC client
type PendingRequest ¶
type PendingRequest struct {
// contains filtered or unexported fields
}
Pending request
type RequestCountListener ¶
type RequestCountListener struct {
// contains filtered or unexported fields
}
Listener for request count
type RequestStartAckListener ¶
type RequestStartAckListener struct {
// contains filtered or unexported fields
}
Listener for request start ack
type StartedRequest ¶
type StartedRequest struct {
// contains filtered or unexported fields
}
Started request. Keep it to indicate the ending.
func (*StartedRequest) End ¶
func (request *StartedRequest) End()
Indicates the ending of the request