Documentation ¶
Index ¶
- Variables
- type ChanResponse
- func (r *ChanResponse) Close()
- func (r *ChanResponse) CloseCh()
- func (r *ChanResponse) CloseWithError(err error)
- func (r *ChanResponse) Done() <-chan struct{}
- func (r *ChanResponse) Err() error
- func (r *ChanResponse) Get() OperationResponse
- func (r *ChanResponse) Next() bool
- func (r *ChanResponse) Send(op OperationResponse)
- type ConnOptions
- type Func
- type Http
- type HttpRequestOption
- type Mock
- type Operation
- type OperationMessage
- type OperationMessageType
- type OperationRequest
- type OperationResponse
- type ProxyResponse
- type RawExtensions
- type Request
- type Response
- type SendResponse
- type SingleResponse
- type Status
- type Transport
- type Upload
- type WebsocketConn
- type WebsocketConnProvider
- type WebsocketHandler
- type Ws
- type WsDialOption
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrClosedConnection = fmt.Errorf("closed connection")
Functions ¶
This section is empty.
Types ¶
type ChanResponse ¶
type ChanResponse struct {
// contains filtered or unexported fields
}
func NewChanResponse ¶
func NewChanResponse(onClose func() error) *ChanResponse
func (*ChanResponse) Close ¶
func (r *ChanResponse) Close()
func (*ChanResponse) CloseCh ¶
func (r *ChanResponse) CloseCh()
func (*ChanResponse) CloseWithError ¶
func (r *ChanResponse) CloseWithError(err error)
func (*ChanResponse) Done ¶
func (r *ChanResponse) Done() <-chan struct{}
func (*ChanResponse) Get ¶
func (r *ChanResponse) Get() OperationResponse
func (*ChanResponse) Next ¶
func (r *ChanResponse) Next() bool
func (*ChanResponse) Send ¶
func (r *ChanResponse) Send(op OperationResponse)
type ConnOptions ¶
type Http ¶
type Http struct { URL string // Client defaults to http.DefaultClient Client *http.Client RequestOptions []HttpRequestOption UseFormMultipart bool }
type HttpRequestOption ¶
type OperationMessage ¶
type OperationMessage struct { ID string `json:"id,omitempty"` Type OperationMessageType `json:"type"` Payload json.RawMessage `json:"payload,omitempty"` }
func (OperationMessage) String ¶
func (msg OperationMessage) String() string
type OperationMessageType ¶
type OperationMessageType string
const ( // GQL_CONNECTION_INIT the Client sends this message after plain websocket connection to start the communication with the server GQL_CONNECTION_INIT OperationMessageType = "connection_init" // GQL_CONNECTION_ERROR The server may responses with this message to the GQL_CONNECTION_INIT from client, indicates the server rejected the connection. GQL_CONNECTION_ERROR OperationMessageType = "conn_err" // GQL_START Client sends this message to execute GraphQL operation GQL_START OperationMessageType = "start" // GQL_STOP Client sends this message in order to stop a running GraphQL operation execution (for example: unsubscribe) GQL_STOP OperationMessageType = "stop" // GQL_ERROR Server sends this message upon a failing operation, before the GraphQL execution, usually due to GraphQL validation errors (resolver errors are part of GQL_DATA message, and will be added as errors array) GQL_ERROR OperationMessageType = "error" // GQL_DATA The server sends this message to transfter the GraphQL execution result from the server to the client, this message is a response for GQL_START message. GQL_DATA OperationMessageType = "data" // GQL_COMPLETE Server sends this message to indicate that a GraphQL operation is done, and no more data will arrive for the specific operation. GQL_COMPLETE OperationMessageType = "complete" // GQL_CONNECTION_KEEP_ALIVE Server message that should be sent right after each GQL_CONNECTION_ACK processed and then periodically to keep the client connection alive. // The client starts to consider the keep alive message only upon the first received keep alive message from the server. GQL_CONNECTION_KEEP_ALIVE OperationMessageType = "ka" // GQL_CONNECTION_ACK The server may responses with this message to the GQL_CONNECTION_INIT from client, indicates the server accepted the connection. May optionally include a payload. GQL_CONNECTION_ACK OperationMessageType = "connection_ack" // GQL_CONNECTION_TERMINATE the Client sends this message to terminate the connection. GQL_CONNECTION_TERMINATE OperationMessageType = "connection_terminate" // GQL_UNKNOWN is an Unknown operation type, for logging only GQL_UNKNOWN OperationMessageType = "unknown" // GQL_INTERNAL is the Internal status, for logging only GQL_INTERNAL OperationMessageType = "internal" )
type OperationRequest ¶
type OperationRequest struct { Query string `json:"query,omitempty"` OperationName string `json:"operationName,omitempty"` Variables map[string]interface{} `json:"variables,omitempty"` Extensions map[string]interface{} `json:"extensions,omitempty"` }
func NewOperationRequestFromRequest ¶
func NewOperationRequestFromRequest(req Request) OperationRequest
type OperationResponse ¶
type OperationResponse struct { Data json.RawMessage `json:"data,omitempty"` Errors gqlerror.List `json:"errors,omitempty"` Extensions RawExtensions `json:"extensions,omitempty"` }
func NewMockOperationResponse ¶
func NewMockOperationResponse(v interface{}, errs gqlerror.List) OperationResponse
func (OperationResponse) UnmarshalData ¶
func (r OperationResponse) UnmarshalData(t interface{}) error
type ProxyResponse ¶
type ProxyResponse struct {
// contains filtered or unexported fields
}
func NewProxyResponse ¶
func NewProxyResponse() *ProxyResponse
func (*ProxyResponse) Bind ¶
func (p *ProxyResponse) Bind(res Response, onOpres func(response OperationResponse, send func()))
func (*ProxyResponse) Bound ¶
func (p *ProxyResponse) Bound(res Response) bool
func (*ProxyResponse) Unbind ¶
func (p *ProxyResponse) Unbind(res Response)
type RawExtensions ¶
type RawExtensions map[string]json.RawMessage
func (RawExtensions) Unmarshal ¶
func (es RawExtensions) Unmarshal(name string, t interface{}) error
type Response ¶
type Response interface { Next() bool Get() OperationResponse Close() CloseWithError(err error) Err() error Done() <-chan struct{} }
func NewErrorResponse ¶
type SendResponse ¶
type SendResponse interface { Response Send(OperationResponse) }
type SingleResponse ¶
type SingleResponse struct {
// contains filtered or unexported fields
}
func NewSingleResponse ¶
func NewSingleResponse(or OperationResponse) *SingleResponse
func (*SingleResponse) Close ¶
func (r *SingleResponse) Close()
func (*SingleResponse) CloseWithError ¶
func (r *SingleResponse) CloseWithError(err error)
func (*SingleResponse) Done ¶
func (r *SingleResponse) Done() <-chan struct{}
func (*SingleResponse) Get ¶
func (r *SingleResponse) Get() OperationResponse
func (*SingleResponse) Next ¶
func (r *SingleResponse) Next() bool
type Transport ¶
func SplitSubscription ¶
SplitSubscription routes subscription to subtr, and other type of queries to othertr
type WebsocketConn ¶
type WebsocketConn interface { ReadJSON(v interface{}) error WriteJSON(v interface{}) error Close() error // SetReadLimit sets the maximum size in bytes for a message read from the peer. If a // message exceeds the limit, the connection sends a close message to the peer // and returns ErrReadLimit to the application. SetReadLimit(limit int64) }
type WebsocketConnProvider ¶
type WebsocketConnProvider func(ctx context.Context, URL string) (WebsocketConn, error)
func DefaultWebsocketConnProvider ¶
func DefaultWebsocketConnProvider(timeout time.Duration, optionfs ...WsDialOption) WebsocketConnProvider
DefaultWebsocketConnProvider is the connections factory A timeout of 0 means no timeout, reading will block until a message is received or the context is canceled If your server supports the keepalive, set the timeout to something greater than the server keepalive (for example 15s for a 10s keepalive)
type WebsocketHandler ¶
WebsocketHandler is default websocket handler implementation using https://github.com/nhooyr/websocket
func (*WebsocketHandler) Close ¶
func (wh *WebsocketHandler) Close() error
func (*WebsocketHandler) ReadJSON ¶
func (wh *WebsocketHandler) ReadJSON(v interface{}) error
func (*WebsocketHandler) WriteJSON ¶
func (wh *WebsocketHandler) WriteJSON(v interface{}) error
type Ws ¶
type Ws struct { URL string // WebsocketConnProvider defaults to DefaultWebsocketConnProvider(30 * time.Second) WebsocketConnProvider WebsocketConnProvider // ConnectionParams will be sent during the connection init ConnectionParams interface{} // contains filtered or unexported fields }
Ws transports GQL queries over websocket Start() must be called to initiate the websocket connection Close() must be called to dispose of the transport
func (*Ws) GetConn ¶
func (t *Ws) GetConn() WebsocketConn
func (*Ws) ResetWithErr ¶
type WsDialOption ¶
type WsDialOption func(o *websocket.DialOptions)
Click to show internal directories.
Click to hide internal directories.